删除NAs时遇到问题。
这是我的代码:
dataset <- read.csv2("my_file.csv", header = T)
year_order <- ret12[order(dataset$year, na.rm = T, decreasing = T), ]
# Returns:
# *Error in order(ret12$year, na.rm = T, decreasing = T) :
# argument lengths differ*
为什么?
答案 0 :(得分:0)
如果你要订购什么并删除在ret12 $ year列中标记为缺失值的NA(通常在order()
- ing中的最后一列),那么你需要订购,然后省略:
year.order <- ret12[ order(ret12$year, decreasing=T),][ 1:sum(!is.na(ret12)), ]