rpart
几天来我一直在努力(试图为我拥有的这个数据集制作分类树),我认为现在是时候询问生命线了 :-) 我确信这很愚蠢我没有看到,但这是我一直在做的事情:
EuropeWater <- read.csv(file=paste("/Users/artessaniccola/Documents/",
"Magic Briefcase/CityTypology/Europe_water.csv",sep=""))
library(rpart)
attach(EuropeWater)
names(EuropeWater)
[1] "City" "waterpercapita_m3" "water_class" "population"
[5] "GDPpercapita" "area_km2" "populationdensity" "climate"
EuropeWater$water_class <- factor(EuropeWater$water_class, levels=1:3,
labels=c("Low", "Medium", "High"))
EuropeWater$climate <- factor(EuropeWater$climate, levels=2:4,
labels=c("Arid", "Warm temperate", "Snow"))
EuropeWater_tree <- rpart(EuropeWater$water_class ~
population+GDPpercapita + area_km2 + populationdensity +
EuropeWater$climate,
data=EuropeWater, method=class)
Error in as.character(x) :
cannot coerce type 'builtin' to vector of type 'character'
对于我的一生,我无法弄清楚错误是关于什么的。