[R] plot rpart tree's from list object

Thomas W Blackwell tblackw at umich.edu
Wed Jun 4 17:15:04 CEST 2003


Christian  -

I am looking at the call to  post()  in the code fragment below,
and I wonder whether all of the arguments that are supplied will
be matched correctly.  I am also reading  help("post.rpart").

The first argument is the tree, and that should be matched okay.
The second argument in the help is named "title.".  It's unusual
to include a period explicitly at the end of an argument name,
and I wonder whether maybe it's needed in order to distinguish
this use of "title" from that in some other function ?

However, the second example at the bottom of the help page seems
to succeed in spite of using "title" without the dot, and it passes
the arguments in the same order as shown in your example ...

Hmmmm.   There are three experiments I would try, if this were
my problem - and NO guarantees that any of them will solve it:

(1) Pass arguments in exactly the order they appear in the
post.rpart() function definition, and use the dot in "title.".
The order is:  tree, title., filename, digits, pretty, use.n, ... .
(This is from R 1.6.2.  Type  post.rpart  (no parentheses) at
the command line prompt to see the function definition in the
version you are using.

(2) Try typing  graphics.off()  at the command line prompt
after the loop has finished.  This is needed in order to get
the last plot into the output file if you have used the
function  postscript()  from base R.

(3) Observe that all 18 filenames generated by  paste() will
be the same.  I think that  paste("Tree","i",sep=".ps")  will
produce  "Tree.psi"  every time.  The i is not interpreted
because it is in quotes.  So each new plot overwrites the
previous one.  An alternative might be:
paste("Tree", i, "ps", sep=".")  giving eg  "Tree.18.ps".

HTH  -  tom blackwell  -  u michigan medical school  -  ann arbor  -


On Wed, 4 Jun 2003, Christian Schulz wrote:

> i want the post plot's from a rpart list object with
> 18 tree's , getting no error - but getting no files,too?
> Perhaps i should using assign!?
>
> for (i in 1:length(treeList)) {
> post(treeList[[i]],filename=paste("Tree","i",sep=".ps"), title="Arbeitszufriedenheit",
> digits=getOption("digits") - 0,use.n=TRUE)
> }
>
> many thanks for help,
> christian




More information about the R-help mailing list