# Predicting from RPart using a subset of variables

I fitted a RPart model from all of a couple dozen variables. Now, I want to test predictions using just a couple of variables that seem significant to me.

If it was the iris dataset, for example, I would have fit the model to all the characteristics but I wanted to test the prediction just from Petal.width and Sepal.length.

When I try making a new dataframe with only those values to enter as newdata, it complains the dataframe is missing Sepal.width, for example.

What am I doing wrong?

• I am not sure if this will be considered on topic here (given the software emphasis). However, in order for anyone to help, I think you will need to provide a few lines of code showing what you tried. Sep 12 '16 at 3:20

mod <- rpart(Species~., iris)
iris2$Petal.Length <- rep(NA, nrow(iris2)) class(iris2$Petal.Length) <- 'numeric'