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

From: Christian Schulz <ozric_at_web.de>
Date: Sun, 16 Dec 2007 20:16:58 +0100


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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 16 Dec 2007 - 19:19:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Dec 2007 - 01:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.