[Rd] text.rpart for the "class" method doesn't act on label="yprob"

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 23 09:10:08 CET 2007


Not sure why this on R-devel!  Nobody has contacted the maintainer, as 
asked by the posting guide.

I've wondered about this in the past.  It seems the argument was dropped 
in rpart3, but the help was not changed.  It is checked but not used.


On Wed, 21 Feb 2007, Robert King wrote:

> Hello All,
>
> Am I misreading the documentation?
>
> The text.rpart documentation says:
> "label   a column name of x$frame; values of this will label the nodes. For
> the "class" method, label="yval" results in the factor levels being
> used, "yprob" results in the probability of the winning factor level being
> used, and ÿÿspecific yval levelÿÿ results in the probability of that factor
> level."
>
> However, yprob doesn't seem to do this:
>> pred = rep(letters[1:6],5)
>> resp = rep(letters[1:3],10)
>> ex.rp <- rpart(resp~pred)
>> plot(ex.rp)
>> text(ex.rp,label="yval")
>
> # works as advertised
>
>> plot(ex.rp)
>> text(ex.rp,label="yprob")
>
> Error in text.rpart(ex.rp, label = "yprob") :
>        Label must be a column label of the frame component of the tree
>
> If I try to fake it, by making an element of the frame, like this:
>> ex.rp$frame$yprob = (ex.rp$frame$n-ex.rp$frame$dev)/ex.rp$frame$n
>
> The text command does add text to the plot, but adds the class labels
> (i.e. "yval"), not the probabilities
>
>> text(ex.rp,label="yprob")
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


More information about the R-devel mailing list