On Mon, 14 Dec 2009, Rebecca O'Leary wrote:
Dear R-users
I am using RPART package to get regression trees. However having
trouble getting the text function to put the full splitting rule
number on the plot, instead to puts it in scientific notation.
When a covariate has 1e4 or greater number of digits then the
splitting rule number displayed on the plot is in scientific
notation. But print.rpart displays the splitting rules in full. I
have tried using digits option in text function but this only alters
digits of the mean displayed at terminal nodes. How do I get the
full splitting rule number displayed on the tree plot?
You change rpart:::labels.rpart, which uses a 'g' format and hence
uses scientific notation if it is more compact.
Below is an example.
library(rpart)
temp <- as.data.frame(cbind(kyphosis, Start2=kyphosis$Start))
temp$Start2 <- temp$Start2+10000
fit1 <- rpart(Age~ Kyphosis +Number + Start2, data=temp)
plot(fit1)
text(fit1, use.n=TRUE, digits=5)
Thanks
Dr Rebecca O'Leary, PhD
Biostatistician
Senior Research Officer
UWA Centre for Child Health Research
Telethon Institute for Child Health Research, 100 Roberts Rd, Subiaco
Perth WA 6008 Australia
Email: role...@ichr.uwa.edu.au
Tel: +61-8-9489 7745
Fax: +61-8-9489 7700
[[alternative HTML version deleted]]
Please send properly formatted text mail without all the blank lines.
--
Brian D. Ripley, rip...@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
______________________________________________
R-help@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.