0

i am trying to plot my decision tree, but it keeps giving me this error, and i can not figure out what is wrong.

here's the code:

install.packages("foreign")
library("foreign")
install.packages("C50")
library(C50)
setwd("C:\\Users\\hp\\Music\\SefSec_2014_HH_weight new.sav")
df <- read.spss("C:\\Users\\hp\\Music\\SefSec_2014_HH_weight new.sav", to.data.frame = TRUE)
View(df)
summary(df)

#summary(df$C12_21)


controlFactor = C5.0Control(sample=0.7,seed=10,CF=0.25,winnow = TRUE ,minCases = 20)
model = C5.0(df[,c(427,432,437,422,447,452,457,462,467,472,482,487,477,492,497,502,503,504,505,506,507,508)], df[,512], control = controlFactor) 
na.omit(df)
summary(model)
plot(model,type="s",main="Descision Tree")

and here's the error:

> plot(model,type="s",main="Descision Tree")
Error in FUN(X[[i]], ...) : Variable match was not found.
  • 1
    Hi, welcome to StackOverflow. It is hard to say what is going wrong here without a reproducible example. In other words, it would be really helpful if you can provide a small dataset and accompanying code that reproduces your error. A guide can be found [here](https://stackoverflow.com/a/5963610/5805670). – slamballais May 16 '21 at 09:21
  • Thank you but I figured out what’s wrong with it, when i removed the sample from the control function it worked, idk why but it worked and i had to split the set into a training and testing set manually. – pinky_dinky_doo400 May 18 '21 at 14:58

0 Answers0