[R] how to run a R program with input arguments

edisonying edisonying1984 at gmail.com
Tue Jul 14 03:09:12 CEST 2009


Thanks for your help. I found another cmd as follows:

   R CMD BATCH  infile  outfile

what's the difference between this expression and commandArgs()? I try to
refer to the instruction of commandArgs but it seems not very helpful.

Henrique Dallazuanna wrote:
> 
> See commandArgs() function.
> 
> On Mon, Jul 13, 2009 at 4:15 PM, edisonying
> <edisonying1984 at gmail.com>wrote:
> 
>>
>> I am a beginner in R and know only a little about it yet. I have a script
>> written in R language, named as "a.txt" for example. I am using a Linux
>> machine, at present I only know that I can type "R" in the terminal and
>> then
>> copy-paste the content in "a.txt" to the R's interface to execute the
>> program. However, I want to know if there is any method that allows me to
>> add some input arguments directly after the "R" in the terminal.
>> Specifically, I want to type the following in the cmd line:
>>
>>   R (some flags or option) a.txt
>>
>> then the program will begin to run. Besides, if the program will read a
>> data
>> file first, can I also specify the data file in the command line? Then
>> the
>> complete command will become:
>>
>>   R  a.txt  data.txt
>>
>> This is important for a beginner. Thanks very much!:working:
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-run-a-R-program-with-input-arguments-tp24465852p24465852.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-run-a-R-program-with-input-arguments-tp24465852p24472126.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list