1

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 ?

4

1 に答える 1

1

そのような施設は見たことがありません。interactive一般的に行われるのは、対話型セッションの場合にのみ TRUE を返す関数を使用して、コードが実行されている条件をテストすることです。

 if (interactive() ){  pdf("myPlot.pdf")
   plot(1:10)
   dev.off()        }

 ?Devices
于 2013-09-18T18:58:11.343 に答える