colSums(Matrix)
colSums()所属R语言包:Matrix
Form Row and Column Sums and Means
表格的行和列的款项和手段
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Form row and column sums and means for Matrix objects.
表格的行和列Matrix对象的款项和手段。
用法----------Usage----------
colSums (x, na.rm = FALSE, dims = 1, ...)
rowSums (x, na.rm = FALSE, dims = 1, ...)
colMeans(x, na.rm = FALSE, dims = 1, ...)
rowMeans(x, na.rm = FALSE, dims = 1, ...)
## S4 method for signature 'CsparseMatrix'
colSums(x, na.rm = FALSE,
dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix'
rowSums(x, na.rm = FALSE,
dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix'
colMeans(x, na.rm = FALSE,
dims = 1, sparseResult = FALSE)
## S4 method for signature 'CsparseMatrix'
rowMeans(x, na.rm = FALSE,
dims = 1, sparseResult = FALSE)
参数----------Arguments----------
参数:x
a Matrix, i.e., inheriting from Matrix.
矩阵,即从Matrix继承。
参数:na.rm
logical. Should missing values (including NaN) be omitted from the calculations?
逻辑。 (包括NaN)被省略计算遗漏值吗?
参数:dims
completely ignored by the Matrix methods.
完全忽略Matrix方法。
参数:...
potentially further arguments, for method <-> generic compatibility.
可能进一步的论据,方法<->通用兼容性。
参数:sparseResult
logical indicating if the result should be sparse, i.e., inheriting from class sparseVector.
逻辑表示如果结果应该是稀疏的,即从类继承sparseVector。
值----------Value----------
returns a numeric vector if sparseResult is FALSE as per default. Otherwise, returns a sparseVector.
返回一个数字矢量sparseResult如果FALSE按默认。否则,返回一个sparseVector。
参见----------See Also----------
colSums and the sparseVector classes.
colSums“sparseVector类。
举例----------Examples----------
(M <- bdiag(Diagonal(2), matrix(1:3, 3,4), diag(3:2))) # 7 x 8[7×8]
colSums(M)
d <- Diagonal(10, c(0,0,10,0,2,rep(0,5)))
MM <- kronecker(d, M)
dim(MM) # 70 80[70 80]
length(MM@x) # 160, but many are '0' ; drop those:[160,但很多都是0;丢弃这些:]
MM <- drop0(MM)
length(MM@x) # 32[32]
cm <- colSums(MM)
(scm <- colSums(MM, sparseResult = TRUE))
stopifnot(is(scm, "sparseVector"),
identical(cm, as.numeric(scm)))
rowSums(MM, sparseResult = TRUE) # 16 of 70 are not zero[70 16不为零]
colMeans(MM, sparseResult = TRUE)
## Since we have no 'NA's, these two are equivalent :[#由于我们有没有“不适用的,这两个是等价的:]
stopifnot(identical(rowMeans(MM, sparseResult = TRUE),
rowMeans(MM, sparseResult = TRUE, na.rm = TRUE)),
rowMeans(Diagonal(16)) == 1/16,
colSums(Diagonal(7)) == 1)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|