Error in eval(predvars, data, env) : object not found.

I am trying to create a prediction, for decision trees. But every time I execute the line below I receive this error. Even though 'tot_proteins' is a column in my dataset. What could be causing this problem?

Prediction1 <- predict(treeFit,newdata=liver.test[-5],type = 'class')

Thank you!

my first thought is that if tot_proteins is the 5th column in liver.test, then you are dropping it

it is the fifth column, but i dont want to drop it. so how do i fix that?

why did you choose to write [-5] ?
why not omit that ?

i have omitted it and now it is working. but I want to create a confusion matrix with it now like this:

confusionMatrix(Prediction1,liver.test$is_patient)

but i receive this error:
Error: data and reference should be factors with the same levels.

what does that mean and how can i fix that ?

I couldnt possible know your factor levels unless you told me...

levels(Prediction1)
levels(liver.test$is_patient)

Hey,
I was able to fix my liver.test$is_patient to not be null. and now it is the same levels as the prediction1. yet it still gives me the same error. any ideas as to why?

Thank you!!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.