當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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'。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。