0

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

RLave
  • 8,144
  • 3
  • 21
  • 37
  • 1
    Hi for people to help better you would need to provide data and code you have tried so far. Please see here how to create a reproducible example :https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Mike Oct 19 '18 at 13:03
  • You probably need `m <- rpart(Calcio ~ . , data = DBRr[1:160,], method = "class")` – G5W Oct 19 '18 at 13:34

0 Answers0