I am trying to create a classification tree with R Studio, with the package rpart.
They are the answers from a survey, in which at the end they registered a consumption level of media usage. I want then, to see if a classification tree can help me out in creating classes of users.
I imported my dataset from excel, randomized, and then run the function:
m <- rpart(Calcio, data = DBRr[1:160,], method = "class")
m : model
Calcio: the last column, representing consumption
DBRr: my randomized dataset (just the first 160 rows, the remaining 80 are for the test)
By inserting that, I see the error:
Error in [.data.frame
(m, labs) : undefined columns selected
How can I fix it? Thank you very much in advance for your help