[R] Writing custom functions for rpart

R Help rhelp.stats at gmail.com
Thu Jan 10 20:04:39 CET 2008


I'm having a similar problem, and after looking through the test
directory I believe I have it down pat, but would someone mind telling
me if I have it correctly, and if not, what I need to fix?

eval: this seems to be the evaluation of a node, used for for labeling
it with whatever decision method is being used.

split: this seems to be the split decision itself.  I have a small
problem here, because I don't understand exactly how this function
will be called.  I assume that, for each covariate in the problem this
will be called ONCE, and then among all the returned "goodness"
values, the largest is chosen and a decision is made.

init: I don't understand the purpose of this function at all, and I
was going to just try and copy the one from anovatest.s, but if
someone can explain it to me it would be appreciated.

I'm also wondering: overall, do my three functions need to accept the
exact same variables that temp1, temp2 and temp3 do?  It seems to me
that they would have to for them to be called by another program, but
if this is the case then I don't know what to do with wt or parms?

Thanks,
Sam Stewart

On May 9, 2007 10:38 AM, hadley wickham <h.wickham at gmail.com> wrote:
> On 5/9/07, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> > On Wed, 9 May 2007, hadley wickham wrote:
> >
> > > Hi everyone,
> > >
> > > Does anyone has experience with (or documentation for) writing custom
> > > methods with rpart? The documentation hints: "Alternatively, 'method'
> > > can be a list of functions 'init', 'split' and 'eval'", but doesn't
> > > provide any details as to what those methods should do or what
> > > arguments they should take etc.
> > >
> > > I've tried looking at the package source (and the source for the S
> > > code it came from) but I can't follow what's going on in C vs R, and
> > > as the default methods are coded in a different way, there are no
> > > examples to follow.
> >
> > But there are, in the tests directory.
>
> Thanks, I had missed those.  Perhaps a pointer from the documentation
> would be appropriate?
>
> Hadley
>
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>




More information about the R-help mailing list