Subassign-methods(Matrix)
Subassign-methods()所属R语言包:Matrix
Methods for "[<-" - Assigning to Subsets for 'Matrix'
“矩阵”的子集分配的方法作“< - ” -
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Methods for "[<-", i.e., extraction or subsetting mostly of matrices, in package Matrix.
包"[<-"Matrix即提取或大多矩阵子集,方法。
Note: Contrary to standadrd matrix assignment in base R, in x[..] <- val it is typically an error (see stop) when the type or class of val would require the class of x to be changed, e.g., when x is logical, say "lsparseMatrix", and val is numeric.
注:相反,以standadrd matrix的转让在基地ŕ,在x[..] <- val它是一个典型的错误(见stop)时的类型或classval需要的类x要改变,例如,当x是逻辑,说"lsparseMatrix",val是数字。
方法----------Methods----------
There are many many more than these:
有很多不止这些:
is currently a simple fallback method implementation which ensures
目前是一个简单的回退方法的实现,从而确保
x = "Matrix", i = "ANY", j = "ANY", value= "ANY" currently
X =“黑客帝国”,“任何”,J =“任何”,值为“任何”目前
x = "denseMatrix", i = "index", j = "missing", value= "numeric" ...
=“denseMatrix”,I =“索引”,J =“失踪”,值为“数字”...
x = "denseMatrix", i = "index", j = "index", value= "numeric" ...
=“denseMatrix”,I =“索引”,J =“索引”,值为“数字”......
x = "denseMatrix", i = "missing", j = "index", value= "numeric" ...
=“denseMatrix”=“失踪”,J =“索引”,值为“数字”...
参见----------See Also----------
[-methods for subsetting "Matrix" objects; the index class; Extract about the standard subset assignment (and extraction).
[-methods子集"Matrix"对象;index类;Extract有关标准的子集分配(提取)。
举例----------Examples----------
set.seed(101)
(a <- m <- Matrix(round(rnorm(7*4),2), nrow = 7))
a[] <- 2.2 # <<- replaces **every** entry[<< - 取代**每**项]
a
## as do these:[#做这些:]
a[,] <- 3 ; a[TRUE,] <- 4
m[2, 3] <- 3.14 # simple number[简单的数字]
m[3, 3:4]<- 3:4 # simple numeric of length 2[简单的数字长度为2]
## sub matrix assignment:[#子矩阵分配:]
m[-(4:7), 3:4] <- cbind(1,2:4) #-> upper right corner of 'm'[ - >右上角的“M”]
m[3:5, 2:3] <- 0
m[6:7, 1:2] <- Diagonal(2)
m
## rows or columns only:[#行或列:]
m[1,] <- 10
m[,2] <- 1:7
m[-(1:6), ] <- 3:0 # not the first 6 rows, i.e. only the 7th[第6行,即只有第7]
as(m, "sparseMatrix")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|