[R] paste dependent variable in formula (rpart)?

Christian Schulz ozric at web.de
Sun Dec 16 20:16:58 CET 2007


Hello,

i'm trying to replace  different  target variables in rpart with a 
function. The data.frame getting always the target variable as last column.
Try below, i get the target variable in the explained variables, too!?  
Have anybody an advice to avoid this.

rp1 <- rpart(eval(parse(text=paste(names(train[length(train)])))) ~ . , 
data=train,cp=0.0001)

regards & many thanks
Christian



More information about the R-help mailing list