[R] R with command line

Duncan Murdoch murdoch.duncan at gmail.com
Wed Apr 28 15:53:45 CEST 2010


On 28/04/2010 9:38 AM, Duke wrote:
> On 4/27/10 8:04 PM, Duncan Murdoch wrote:
> > On 27/04/2010 6:15 PM, Duke wrote:
> >> Hi all,
> >>
> >> I am testing R by trying R on command line (ie without opening R 
> >> console) on a Mac Pro with 10.6. So I created a file plot.R:
> >>
> >> x11(width=5,height=3.5)
> >> plot(1:10,1:10)
> >>
> >> So I have two questions below (please forgive me if the questions 
> >> have been asked already)
> >>
> >> 1. What is the different between *R CMD BATCH infile.R* and *R 
> >> --vanilla --slave < infile.R*?
> >
> > Those are quite similar.  A couple of differences are:
> >
> > --vanilla changes the startup options.  You'll use fewer of the 
> > profile etc. files.  See ?Startup for the details.
> >
> >  R CMD BATCH sets up an output file to collect the output.  It would 
> > likely be called infile.Rout.  It would also have a proc.time() call 
> > added at the end.
>
> Got it now. Thanks Duncan.
>
> >
> >> 2. When I ran plot.R with one of the above methods, the plot showed 
> >> up for like a second and disappear. What should I do to keep the plot 
> >> there until the user closes it?
> >
> > If you have a user involved, you should be running interactively, not 
> > in batch mode. You can automatically run your infile.R ahead of 
> > starting the session by setting an environment variable named 
> > R_PROFILE_USER pointing to that file; e.g.
> >
> > R R_PROFILE_USER=infile.R
> >
> > (which sets the variable temporarily, only for that session).
>
> Well, it seems to be beyond my understanding. Could you please elaborate 
> a little bit more?

Just type the line I gave you.  I don't really see how to elaborate.

Duncan Murdoch



More information about the R-help mailing list