Skip to content

Rpart plot produces no text

3 messages · Thompson, James, John Kane, Achim Zeileis

#
I am using R Studio and am able to fit a tree with RPlot, however, the tree in the viewer has no text (see image attached).

Jim Thompson
This e-mail message is for the sole use of the intended recipient and may contain information that is confidential, proprietary or privileged. Any unauthorized review, use, distribution, copying or disclosure is strictly prohibited. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, please notify sender of the delivery error by replying to this message and then delete it from your system. Receipt by anyone other than the intended recipient is not a waiver of confidentiality or privilege.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot_test.png
Type: image/png
Size: 5236 bytes
Desc: Rplot_test.png
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160628/4da519eb/attachment.png>
#
What happens if you run the code in a terminal rather than RStudio? My experience is that very, very occasionally RStudio does something a bit funny with plots.  

And while this may sound funny just shut down RStudio, reload it and try again. 

John Kane
Kingston ON Canada
#
I don't think this is an RStudio issue. The plot() method for "rpart" 
objects draws no labels. The text() method has to be called additionally:

library("rpart")
rp <- rpart(Species ~ ., data = iris)
plot(rp)
text(rp)

As these plots produced by rpart itself are not very appealing, there are 
various approaches that allow drawing other displays, e.g.,

library("rpart.plot")
prp(rp)

library("rattle")
fancyRpartPlot(rp)

library("partykit")
plot(as.party(rp))

which show different amounts of detail and use different visual means to 
display the available information.
On Wed, 29 Jun 2016, John Kane wrote: