I am layman to unix and sofar I using R in windows. For example I type following in my R session (in R gui).
# this is a my funny example script
X <- 1:
Assuming you save your script in a simple text file with the name so.R, you can run it under Linux/Unix by typing R at the prompt. Once in R enter
source('so.R')
to execute the script inside the R environment (this assumes the so.R file is in the same directory as you are when you issue this command).
To run the script from the Linux/Unix command line use the following command:
R CMD BATCH so.R
Note that I got the plot to show when I ran the script inside of R, but from the Linux command line it doesn't show. I suspect it gets quickly displayed and then goes away, so there will be a R command that you have to look up to make it pause after it displays the plot.