[R] Problem plotting output from tree()

Ian Robertson igr at stanford.edu
Fri Nov 13 22:18:45 CET 2009


I am using tree() in some classification work, and have been trying to 
suppress the number of significant digits shown in the output plot. 
There is a "digits" parameter that can be used in text.tree(), but I 
can't seem to make it have any effect. Here is some example code to 
illustrate what I mean:

####################################################
#some fake data
    set.seed(123)
    f1 <- factor(rep(1:4, 50))
    m1 <- matrix(runif(800), nc=4)
    d1 <- data.frame(f1, m1)
#the test
    library(tree)
    mdl1 <- tree(f1 ~ ., data=d1)
#(messy) output
    plot(mdl1); text(mdl1, cex=.6)
    plot(mdl1); text(mdl1, cex=.6, digits=2) #no change to labelling
#help!
    ?text.tree
####################################################

Can anyone spot my error? Many thanks for any help.

Ian Robertson




More information about the R-help mailing list