0
我正在嘗試對dataframe列進行計算,但由於該列包含級別,因此儘管使用了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