I am trying to create a classification tree in R using the package tree.
This is an excerpt of the dataset I am using (header included):
CENTRO_EXAMEN,NOMBRE_AUTOESCUELA,MES,TIPO_EXAMEN,NOMBRE_PERMISO,PROB
Alcal· de Henares,17APTOV,5,PRUEBA DESTREZA,A2 ,0
Alcal· de Henares,17APTOV,5,PRUEBA CONDUCCION Y CIRCULACION,B ,0.8
Alcal· de Henares,17APTOV,5,PRUEBA TEORICA,B ,0.333333333
Alcal· de Henares,2000,5,PRUEBA TEORICA,B ,0
and this is the commands I am issuing to R:
madrid=read.csv("madrid.csv",header=T,na.strings="?")
#madrid=na.omit(madrid)
names(madrid)
dim(madrid)
fix(madrid)
library(tree)
attach(madrid)
#costruisce albero
High=ifelse(PROB<=0.5,"No","Yes")
madrid=data.frame(madrid,High)
tree.madrid=tree(High~CENTRO_EXAMEN+NOMBRE_AUTOESCUELA+MES+TIPO_EXAMEN+NOMBRE_PERMISO,madrid)
summary(tree.madrid)
plot(tree.madrid)
text(tree.madrid,pretty=0)
tree.madrid
R returns the following error after issuing tree.madrid
Error in tree(High ~ CENTRO_EXAMEN + NOMBRE_AUTOESCUELA + MES + TIPO_EXAMEN + :
factor predictors must have at most 32 levels
Any idea why?