Skip to content
Prev 177534 / 398503 Next

Question about rpart(sth~.,database)

Grze? wrote:
It means include all remaining variables in HouseVotes84 on the rhs of 
the formula, i.e. as variables that should be used to predict the Class 
variable.
Why does this surprise you? You are now trying to predict the variable 
V2 (y/n) from Class and all remaining variables.
They are solutions to two different problems.

If you want to predict Class, then you need

Class ~ ., data = HouseVotes84

or, to specify exactly which variables to use as predictors of Class, 
state them explicitly:

Class ~ V1 + V3 + V4, data = HouseVotes84

I think you should look at the documentation that comes with R (An 
Introduction to R) or some of the contributed help documents on the R 
Website to read up on model formulae and how to represent models using 
this notation.

HTH

G