找不到功能colMedians

时间:2017-02-21 14:10:54

标签: r

我看过enter image description here,我添加了包MatrixStats

但是当我运行代码时

colMeans(adult_csv[5], na.rm = TRUE)
colMedians(adult_csv[5], na.rm = TRUE)

它传递了第一行,但是抱怨colMedians

  

R:找不到功能colMedians

1 个答案:

答案 0 :(得分:3)

colMeans()位于basecolMedians位于matrixStats包中。

find("colMedians")
#  [1] "package:matrixStats"
find("colMeans")
#  [1] "package:base"

首先附上包裹:

library(matrixStats)
colMeans(adult_csv[5], na.rm = TRUE)
colMedians(adult_csv[5], na.rm = TRUE)