This question shows research effort; it is useful and clear
0
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
使用 R,我试图找到一列的平均值,但我似乎无法让它工作。这是我的代码:
mean(data_frame$column, na.rm = TRUE)
当我运行它时,它只会给我一条错误消息:argument is not numeric or logical: returning NA. 我也尝试过使用colMeans它,只是给出另一个错误消息:'x' must be an array of at least two dimensions。我究竟做错了什么?
# remove NA value
data_frame <- data_frame[!(is.na(data_frame$column) | data_frame$column==""),]
# calculate the mean
mean <- mean(data_frame[["column"]])