[R] User defined split function in rpart

Tobias Guennel tguennel at vcu.edu
Sun Feb 18 22:10:46 CET 2007


Dear R community,

I am trying to write my own user defined split function for rpart. I read
the example in the tests directory and I understand the general idea of the
how to implement user defined splitting functions. However, I am having
troubles with addressing the data frame used in calling rpart in my split
functions. 
For example, in the evaluation function that is called once per node, I want
to fit a proportional odds model to the data in the node and use its
deviance as node deviance:

evalf <- function(y,x,parms) {
       
pomnode<-polr(dataframe$y~dataframe$x,dataframe,weights=dataframe$Freq)

more code
}

The dataframe used in the polr call should be the data of the current node.
How can I address the data of the current node and assign it to the
dataframe?


Thank you for your help,
Tobias Guennel



More information about the R-help mailing list