当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R Subscript-methods “[”的方法:在“Matrix”包中提取或取子集


R语言 Subscript-methods 位于 Matrix 包(package)。

说明

"[" 的方法,即大部分矩阵的提取或子集,位于包 Matrix 中。

方法

还有更多:

x = "Matrix",i = "missing",j = "missing",下降= "ANY"

...

x = "Matrix",i = "numeric",j = "missing",下降= "missing"

...

x = "Matrix",i = "missing",j = "numeric",下降= "missing"

...

x = "dsparseMatrix",i = "missing",j = "numeric",下降= "logical"

...

x = "dsparseMatrix",i = "numeric",j = "missing",下降= "logical"

...

x = "dsparseMatrix",i = "numeric",j = "numeric",下降= "logical"

...

例子



str(m <- Matrix(round(rnorm(7*4),2), nrow = 7))
stopifnot(identical(m, m[]))
m[2, 3]   # simple number
m[2, 3:4] # simple numeric of length 2
m[2, 3:4, drop=FALSE] # sub matrix of class 'dgeMatrix'
## rows or columns only:
m[1,]     # first row, as simple numeric vector
m[,1:2]   # sub matrix of first two columns

showMethods("[", inherited = FALSE)

也可以看看

[<-methods 用于对 "Matrix" 对象进行子分配。 Extract 关于标准提取。

相关用法


注:本文由纯净天空筛选整理自R-devel大神的英文原创作品 Methods for "[": Extraction or Subsetting in Package 'Matrix'。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。