0

I am making some graphs with R and I am coping them to Word. I was coping them as metafiles but Word doesn't seem to be able to cope with them. The other option in R to copy graphs is a bitmap, but when I use this the quality of the graphs in word is terrible.

I saw some answers about changing the resolution in this website but only if I saved the graphs which I would like to avoid. Is there a way of changing the resolution for copied graphs?

Thanks,

sbg

sbg
  • 1,772
  • 8
  • 27
  • 45

1 Answers1

5

When the graphs are onscreen, they are drawn for a screen resolution (i.e. 72dpi). For print, you need to use at least 300dpi, or switch to a vector format. Word can import graphs in Windows Metafile (.wmf) format; but your other option is to save the plot using, e.g.,

png("my plot.png", res = 300)
plot(1:5)
dev.off()

This saves to disk, which you said you wanted to avoid, but you can always delete it again later (programatically even, with file.remove).

I'd also like to make the case that when you copy and paste, your work isn't as easily reproducible as when you use code. There is no trace of what you have done, and when your data changes, you need to go through the rigmarole of clicking again, rather than just executing your updated script.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • 1
    What Richie is saying (right?) is, check out Sweave (http://www.stat.umn.edu/~charlie/Sweave/). – Roman Luštrik Jul 20 '11 at 12:11
  • From a reproducibility viewpoint working with the clipboard is not recommended as it behaves differently across systems. I encountered the same problem when trying to make a javascript copy text to the clipboard off a website and it turned out to be notoriously difficult. – Backlin Jul 20 '11 at 12:47
  • @Roman: Saving your plot rather than copying & pasting is good. Sweaving is even better. – Richie Cotton Jul 20 '11 at 12:55