【发布时间】:2015-09-28 13:37:17
【问题描述】:
我正在尝试对数据框列进行计算,但由于该列包含级别,尽管我使用了 droplevels 命令(来自this 帖子),但它们一直失败。我在这里做错了什么:
csv <- data.frame(col1 = c("question",1,23,2,5,6), col2 = c("question",5,6,7,3,""))
csv[csv==''] <- NA
csv <- csv[-c(1),] #remove the header question row because this screws up numeric calculations
csv <- droplevels(csv)
csv[,1] <- 7-csv[,1]
我明白了:
Warning message:
In Ops.factor(7, csv[, 1]) : ‘-’ not meaningful for factors
【问题讨论】:
标签: r