Hi, Does any one know if it is possible to create an R script that can use command line parameters. I can execute an R script from the command line, but I cannot figure out how to pass parameters to the script. The only resources I have found seem somewhat involved or incomplete. Any help is appreciated. Akintayo [[alternative HTML version deleted]]
Does system("command -arguments") works for you?
Xiaohui
akintayo holder wrote:> Hi,
> Does any one know if it is possible to create an R script that can use
> command line parameters. I can execute an R script from the command line,
> but I cannot figure out how to pass parameters to the script. The only
> resources I have found seem somewhat involved or incomplete.
>
> Any help is appreciated.
> Akintayo
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
probably you're looking for ?commandArgs().
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "akintayo holder" <blakdogg at gmail.com>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, March 06, 2007 9:11 AM
Subject: [R] Passing command line parameters to a script
> Hi,
> Does any one know if it is possible to create an R script that can
> use
> command line parameters. I can execute an R script from the command
> line,
> but I cannot figure out how to pass parameters to the script. The
> only
> resources I have found seem somewhat involved or incomplete.
>
> Any help is appreciated.
> Akintayo
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
#!/bin/sh
echo 'a="${1}"; b="${2}";
source("myRcodeUsing_a_and_b.R"); ' | R
--vanilla --quiet
and you can run this from shell like:
./callR valueOfa valueOfb
Best, Oleg
akintayo holder wrote:> Hi,
> Does any one know if it is possible to create an R script that can use
> command line parameters. I can execute an R script from the command line,
> but I cannot figure out how to pass parameters to the script. The only
> resources I have found seem somewhat involved or incomplete.
>
> Any help is appreciated.
> Akintayo
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
--
Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466
Reasonably Related Threads
- Getting R to emit an image file as a pipe or Base64 stream: Mac OSX 10.3 - R 2.0.1
- Background R session on Unix and SIGINT
- Background R session on Unix and SIGINT
- Getting R to emit an image file as a pipe or Base64 strea m: Mac OSX 10.3 - R 2.0.1
- withr::set_makevars