3

I am working with a script that looks something like this:

testplot <- plot(fit, uniform=TRUE, 
    main="Classification Tree for MRC")
text(fit, use.n=TRUE, all=TRUE, cex=.8)

post(fit, file = "tree.ps", 
    title = "Classification Tree")

I'm not that familiar with how R handles images/plotting, but is there any way to generate a png or pdf file of the image instead of postscript format? I see in some tutorials that the demo images are in PNG's, but they all only show the post method of saving the plot. Do I have to convert the image outside of the script?

rhae66
  • 293
  • 1
  • 4
  • 8
  • 2
    have a look at `?pdf` and `?png` – Nishanth May 07 '13 at 17:07
  • Possibly [this](http://stackoverflow.com/questions/6227020/how-to-resize-and-save-plots-in-png-format) question might also help? – Adam Kimberley May 07 '13 at 17:08
  • Thanks, to both of you! That got me moving in the right direction :) – rhae66 May 07 '13 at 17:19
  • I don't know if it's appropriate to ask this here, but is there any documentation on how `plot` or `text` allocates margin space? There's one part of the the text in the `png` version of my plot that now gets cut off on the right side... – rhae66 May 07 '13 at 17:41
  • `?par` for margin allocation. Look `mar` and `oma` and `xpd`. Can also include "\n" for line-breaks/word-wrap. – IRTFM May 07 '13 at 18:54

1 Answers1

1

My advice would be to consider using RStudio. It makes this very easy - there is a 'save image' button which allows you to specify the type of image (e.g., pdf, png, etc) and the size.