dmeu
dmeu

Reputation: 4052

R: Does R know if code is being executed as script or in a open R session (terminal)

I have code which sometimes I execute from within Rstudio, which has a nice plotter window. But the other times I execute it on a distant machine per command line.

Thus, I would like to know if there is some R environment variable that tells me if I am running code in an open terminal or via Rscript. If yes, I could decide to print the plots into a file or standard out.

Thanks for any hints!

Upvotes: 0

Views: 77

Answers (1)

sgibb
sgibb

Reputation: 25736

Have a look at the ?interactive command.

Upvotes: 3

Related Questions