How can I run something like source("filename") from the Unix command line? Maybe somthing like ./R CMD source("filename") - this does not work. I need to run an R source code file with a command from the Unix command line. assuming that I have R installed on my system. Thank you all Amir. -- View this message in context: http://www.nabble.com/Running-source-from-Unix-line-tf3196035.html#a8874226 Sent from the R help mailing list archive at Nabble.com.
How can I run something like source("filename") from the Unix command line? Maybe somthing like ./R CMD source("filename") - this does not work. I need to run an R source code file with a command from the Unix command line. assuming that I have R installed on my system. Thank you all Amir. -- View this message in context: http://www.nabble.com/Running-source-from-Unix-line-tf3196037.html#a8874240 Sent from the R help mailing list archive at Nabble.com.
On Thu, 8 Feb 2007, Amir Herman wrote:> > How can I run something like source("filename") from the Unix command line? > Maybe somthing like ./R CMD source("filename") - this does not work. > > I need to run an R source code file with a command from the Unix command > line. > assuming that I have R installed on my system.Appendix B of manual An Introduction to R: http://cran.r-project.org/doc/manuals/R-intro.html#Invoking-R-from-the-command-line is helpful, or see ?Startup, or google littler R script. For the time being, think echo 'source("filename")' | R [options], or cat filename | R> > Thank you all > Amir. > >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
See the previous reply, but also if you want to run a shell script and need to pass arguments like file names or dir names or anything else, you cane you the following (${1} -- 1st argument to the shell script, ${2} -- second etc): #!/bin/sh echo 'a="${1}";b="${2}"; source("codeWith_a_and_b.R")" | R --vanilla --quiet The from shell (e.g. to process smth in this dir, a, with b=2): ./thisScript `pwd` 2 Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Amir Herman wrote:> How can I run something like source("filename") from the Unix command line? > Maybe somthing like ./R CMD source("filename") - this does not work. > > I need to run an R source code file with a command from the Unix command > line. > assuming that I have R installed on my system. > > Thank you all > Amir. >