[R] how to label the branches of a tree

David Winsemius dwinsemius at comcast.net
Wed Feb 25 19:01:59 CET 2009


How do you want the labels to appear? Each branch will be the logical  
conjunction of the criteria for *all* of the upstream splits. Perhaps  
you can get direction by looking at the code of text.rpart:

getAnywhere(text.rpart)

Any split would need to add an "& Split-N yes" or an "& Split-N No" to  
any lower branch.

-- 
David Winsemius

On Feb 25, 2009, at 10:44 AM, Utkarsh Singhal wrote:

> Hi David,
>
> May be I was not clear, but I want to label the branches itself and  
> not the branching points or the leaves.
>
> Regards
> Utkarsh
>
> From: Philip Twumasi-Ankrah [mailto:nana_kwadwo_derkyi at yahoo.com]
> Sent: Wednesday, February 25, 2009 9:07 PM
> To: Utkarsh Singhal
> Cc: R-help Forum
> Subject: Re: [R] how to label the branches of a tree
>
> You may have to change/scale the sizes of the font by using "cex"  
> and then to keep all labels within the plotting window, use  
> "xpd=TRUE". Like in
> text(fit, use.n=TRUE, cex=0.8, xpd=TRUE)
> Philip
> --
> A Smile costs Nothing But Rewards Everything
>                                                               -  
> Anonymous
>
> Happiness is not perfected until it is shared
>                                                               -Jane  
> Porter
>
>
> --- On Wed, 2/25/09, David Winsemius <dwinsemius at comcast.net> wrote:
> From: David Winsemius <dwinsemius at comcast.net>
> Subject: Re: [R] how to label the branches of a tree
> To: "Utkarsh Singhal" <utkarshs at ambaresearch.com>
> Cc: "R-help Forum" <r-help at r-project.org>
> Date: Wednesday, February 25, 2009, 7:28 AM
> When I execute that code, I get labels both on the branching points  
> and at the
>
> leaves of the tree. So I guess my reply is "cannot reproduce" or
>
> "do not understand".  They are however not properly positioned and the
>
> edges and
>  bottoms of some of the labels are cut off, but that did not sound  
> like
>
> your question.
>
>
>
> Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version  
> 3.1-42.
>
>
>
> --David Winsemius
>
>
>
> Note:  your mailer is putting single quotes inside the enclosing  
> angle brackets
>
> so my mailer does not recognize the r-help address as a valid  
> address. Since
>
> this is the first time I have encountered this construction, I  
> wonder if your
>
> mailer is adhering to standards in its reply-to functions.
>
>
>
>
>
>
>
> On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:
>
>
>
> > Hi,
>
> >
>
> >
>
> >
>
> > I am using rpart package to fit classification trees.
>
> >
>
> >
>
> >
>
> > library(rpart)
>
> >
>
> > fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
>
> >
>
> > plot(fit,uniform=T)
>
> >
>
> > text(fit, use.n=TRUE)
>
> >
>
> >
>
> >
>
> > But I am unable to label the branches (not
>  the nodes) of the tree. Can
>
> somebody help me out in this?
>
> >
>
> >
>
> >
>
> > Thank you,
>
> >
>
> > Regards
>
> >
>
> > Utkarsh Singhal | Amba Research
>
> >
>
> > Ph +91 80 3980 8017 | Mob +91 99 0295 8815
>
> >
>
> > Bangalore * Colombo * London * New York * San José * Singapore *
>
> www.ambaresearch.com  <mailto:utkarshs at ambaresearch.com>
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > This e-mail may contain confidential and/or privileged i... 
> {{dropped:13}}
>
> >
>
> > ______________________________________________
>
> > 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.
>
>
>
> ______________________________________________
>
> 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.
>
> This e-mail may contain confidential and/or privileged...{{dropped:12}}




More information about the R-help mailing list