I'm on linux (LMDE).
I have this script that plots many stuff with the classical graphics and ggplot. Sometimes I also call pdf()
or png()
, but sometimes I just let the default grDevice pop up and display it for me (RStudioGD or x11())
The problem is that when I execute this script from Rscript with a different user (in my case, the apache www-data), it may raise permission problems, especially for the default device, when I have not preloaded any other device. (e.g.: Error in (function (file = ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"), :
cannot open file 'Rplots.pdf'
Calls: source ... barplot -> barplot.default -> dev.hold ->
)
I would like to be able to just discard any of these plots (or even all plots) by just one or two lines at the beginning (and the end) of my script. Something like nullDevice()
/ script / dev.off()
that will ensure that at least the default graphs are piped to something harmless.
Any idea ?