计算基础统计量
Use one of these functions as appropriate, assuming that x and y are vectors:
公卫论坛
mean(x)median(x)
sd(x)
var(x)
cor(x, y)
cov(x, y)
Does an NA in your data invalidate the statistic? If yes,
then R is doing the right thing. If not, you can override this behavior by setting
na.rm=TRUE, which tells R to ignore the NA values:
> x <- c(0,1,1,2,3,NA)
> mean(x, na.rm=TRUE)
[1] 1.4
> sd(x, na.rm=TRUE)
[1] 1.140175
then R is doing the right thing. If not, you can override this behavior by setting
公卫家园
na.rm=TRUE, which tells R to ignore the NA values:
> x <- c(0,1,1,2,3,NA)
> mean(x, na.rm=TRUE)
[1] 1.4
> sd(x, na.rm=TRUE)
[1] 1.140175
附件列表
词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。