[R] R with command line

Duke duke.lists at gmx.com
Wed Apr 28 16:03:08 CEST 2010


On 4/28/10 9:53 AM, Duncan Murdoch wrote:
> 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.

I just did it, and it said it ignored the arg:

$ R R_PROFILE_USER=try.R
ARGUMENT 'R_PROFILE_USER=try.R' __ignored__


R version 2.11.0 (2010-04-22)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

   Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

 >

What am I doing wrong?

Thanks,

D.

>
> Duncan Murdoch
>



More information about the R-help mailing list