这是一行,
colMeans3 <- colMeans(grade3, na.rm=TRUE)
和R说
Error in colMeans(grades3, na.rm = TRUE) : 'x' must be numeric
答案 0 :(得分:2)
子集grade3
仅包含数字变量。
grade3 <- data.frame(a = runif(10), b = rnorm(10), c = letters[1:10])
colMeans(grade3)
find.numeric <- sapply(grade3, is.numeric)
colMeans(grade3[, find.numeric])
a b
0.4675017 0.1642704