Dear useRs: I try to plot an rpart object but cannot get a nice tree structure plot. I am using plot.rpart and text.rpart (please see below) but the branches that connect the nodes overlap the text in the ellipses and rectangles. Is there a way to get a clean nice tree plot (as in the Rpart Mayo report)? I work under Windows and use R2.11.1 with rpart version 3.1-46. Thank you. Tudor ... plot(cart, uniform=TRUE, branch=0.25, compress=TRUE, margin=0.25) text(cart, use.n=TRUE, all=TRUE, fancy=TRUE, fheight=0.95) ... -- View this message in context: http://r.789695.n4.nabble.com/Rpart-decision-tree-tp3435888p3435888.html Sent from the R help mailing list archive at Nabble.com.
Rpart decision tree
6 messages · Tudor Bodea, Tal Galili, Achim Zeileis
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110408/714717e8/attachment.pl>
On Fri, 8 Apr 2011, tudor wrote:
Dear useRs: I try to plot an rpart object but cannot get a nice tree structure plot. I am using plot.rpart and text.rpart (please see below) but the branches that connect the nodes overlap the text in the ellipses and rectangles. Is there a way to get a clean nice tree plot (as in the Rpart Mayo report)? I work under Windows and use R2.11.1 with rpart version 3.1-46.
You could check out whether you like the plots generated in the "party"
package better. See example("ctree", package = "party").
If you like the plots but don't want to use ctree() instead of rpart():
Then you could install the "partykit" package from R-Forge and then do
plot(as.party(...)) for your "rpart" object.
hth,
Z
Thank you. Tudor ... plot(cart, uniform=TRUE, branch=0.25, compress=TRUE, margin=0.25) text(cart, use.n=TRUE, all=TRUE, fancy=TRUE, fheight=0.95) ... -- View this message in context: http://r.789695.n4.nabble.com/Rpart-decision-tree-tp3435888p3435888.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Hi Tal: Thanks for your quick reply. I tried to create a classification tree. The problem is that the branches overlap the text in the ellipses (inner nodes) and rectangles (terminal nodes) - At times this makes it difficult for the reader to correctly process the results. One way to overcome this behavior would be to force the node connectors to show only outside of ellipses and rectangles - so far, however, I could not implement this behavior. Tudor -- View this message in context: http://r.789695.n4.nabble.com/Rpart-decision-tree-tp3435888p3437211.html Sent from the R help mailing list archive at Nabble.com.
Hi Achim: I will give it a try and let you know how it goes. Thanks. Tudor -- View this message in context: http://r.789695.n4.nabble.com/Rpart-decision-tree-tp3435888p3437212.html Sent from the R help mailing list archive at Nabble.com.
Dear Tal and Achim: Thank you both for your assistance. I followed Achim's suggestions and got what I needed on a Windows machine with R2.12.2 installed. As I needed to run the task on a Windows machine with R2.11.1 I used the package rpart.plot (by Stephen Milborrow) to create my charts. Best regards, Tudor -- View this message in context: http://r.789695.n4.nabble.com/Rpart-decision-tree-tp3435888p3437345.html Sent from the R help mailing list archive at Nabble.com.