Rebecca O'Leary
2009-Dec-14 04:11 UTC
[R] RPART - printing full splitting rule number on tree plot
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? 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: roleary@ichr.uwa.edu.au Tel: +61-8-9489 7745 Fax: +61-8-9489 7700 ##################################################################################### This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal ##################################################################################### [[alternative HTML version deleted]]
Prof Brian Ripley
2009-Dec-14 08:25 UTC
[R] RPART - printing full splitting rule number on tree plot
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: roleary at 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, 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
Seemingly Similar Threads
- for plots
- ?to calculate sth for groups defined between points in one variable (string), / value separating/ spliting variable into groups by i.e. between start, NA, NA, stop1, start2, NA, stop2
- Saving misclassified records into dataframe within a loop
- [LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?
- [LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?