0
tree <- rpart(hit ~. , data = train, control = rpart.control(minbucket = 5))
plot(tree, main = "Decision Tree")
text(tree)

Decision tree plot

(I deleted independent variable names from the image)

My problem is that factor names written as 'a', 'b', 'c', bcdefghijl', and 'bfgj' etc., instead of the real factor names. I tried both of the code below, but not resolving the issue. How to fix it?

df$var1<-as.factor(df$var1)
df$var1<-as.factor(as.character(df$var1))
rocknRrr
  • 341
  • 1
  • 10

1 Answers1

1

Wrong labels in rpart tree

I found this link has good answer for this. just don't use rpart plot, but lbrary(rpart.plot)

rocknRrr
  • 341
  • 1
  • 10