找回密码
 注册
查看: 3432|回复: 0

R语言:colSums()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 19:29:40 | 显示全部楼层 |阅读模式
colSums(base)
colSums()所属R语言包:base

                                        Form Row and Column Sums and Means
                                         表格的行和列的款项和手段

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Form row and column sums and means for numeric arrays.
形成行和列的款项和数字阵列手段。


用法----------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)



参数----------Arguments----------

参数:x
an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame.
两个或两个以上维度的阵列,包含数字,复杂的,整数或逻辑值或数字数据框。


参数:na.rm
logical.  Should missing values (including NaN) be omitted from the calculations?
逻辑。 (包括NaN)被省略计算遗漏值吗?


参数:dims
integer: Which dimensions are regarded as "rows" or "columns" to sum over.  For row*, the sum or mean is over dimensions dims+1, ...; for col* it is over dimensions 1:dims.
整数:哪些方面是“行”或“列”来概括以上。 ,row*的总和或平均尺寸是dims+1, ...;col*以上尺寸是1:dims。


Details

详情----------Details----------

These functions are equivalent to use of apply with FUN = mean or FUN = sum with appropriate margins, but are a lot faster.  As they are written for speed, they blur over some of the subtleties of NaN and NA.  If na.rm =     FALSE and either NaN or NA appears in a sum, the result will be one of NaN or NA, but which might be platform-dependent.
这些功能是相当于apply的使用FUN = mean或FUN = sum适当的利润,但速度快了很多。因为他们是写入速度,他们模糊过一些NaN和NA的奥妙。如果na.rm =     FALSE或者NaN或NA中出现的总和,其结果将是一个NaN或NA,但它可能是依赖于平台的。

Notice that omission of missing values is done on a per-column or per-row basis, so column means may not be over the same set of rows, and vice versa.  To use only complete rows or columns, first select them with na.omit or complete.cases (possibly on the transpose of x).
注意遗漏,遗漏值是每列或每行的基础上完成的,所以列方式可能不超过相同的行集,反之亦然。只使用完整的行或列,首先选择与na.omit或complete.cases(可能x转)。


值----------Value----------

A numeric or complex array of suitable size, or a vector if the result is one-dimensional.  The dimnames (or names for a vector result) are taken from the original array.
一个合适的大小,或如果结果是一维的向量的数字或复杂的阵列。 dimnames(或names为向量的结果),从原来的阵列。

If there are no values in a range to be summed over (after removing missing values with na.rm = TRUE), that component of the output is set to 0 (*Sums) or NaN (*Means), consistent with sum and mean.
如果在一定范围内有没有值以上(去除na.rm = TRUE遗漏值),该组件的输出设置为0(*Sums)NaN后总结(*Means),sum和mean一致。


参见----------See Also----------

apply, rowsum
apply,rowsum


举例----------Examples----------


## Compute row and column sums for a matrix:[#计算一个矩阵的行和列的款项:]
x <- cbind(x1 = 3, x2 = c(4:1, 2:5))
rowSums(x); colSums(x)
dimnames(x)[[1]] <- letters[1:8]
rowSums(x); colSums(x); rowMeans(x); colMeans(x)
x[] <- as.integer(x)
rowSums(x); colSums(x)
x[] <- x < 3
rowSums(x); colSums(x)
x <- cbind(x1 = 3, x2 = c(4:1, 2:5))
x[3, ] <- NA; x[4, 2] <- NA
rowSums(x); colSums(x); rowMeans(x); colMeans(x)
rowSums(x, na.rm = TRUE); colSums(x, na.rm = TRUE)
rowMeans(x, na.rm = TRUE); colMeans(x, na.rm = TRUE)

## an array[#数组]
dim(UCBAdmissions)
rowSums(UCBAdmissions); rowSums(UCBAdmissions, dims = 2)
colSums(UCBAdmissions); colSums(UCBAdmissions, dims = 2)

## complex case[#复杂的情况下]
x <- cbind(x1 = 3 + 2i, x2 = c(4:1, 2:5) - 5i)
x[3, ] <- NA; x[4, 2] <- NA
rowSums(x); colSums(x); rowMeans(x); colMeans(x)
rowSums(x, na.rm = TRUE); colSums(x, na.rm = TRUE)
rowMeans(x, na.rm = TRUE); colMeans(x, na.rm = TRUE)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-24 16:47 , Processed in 0.018981 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表