Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Passing parameters to R script

by erix (Prior)
on Oct 15, 2007 at 19:06 UTC ( [id://645004]=note: print w/replies, xml ) Need Help??


in reply to Passing parameters to R script

# test.R:

cat("-- reading arguments\n", sep = ""); cmd_args = commandArgs(); for (arg in cmd_args) cat(" ", arg, "\n", sep="");

# command line:

R --slave --no-save --no-restore --no-environ --silent --args arg1=abc + < test.R

# output from R:

-- reading arguments /home/aardvark/lib/R/bin/exec/R --slave --no-save --no-restore --no-environ --silent --args arg1=abc

Replies are listed 'Best First'.
Re^2: Passing parameters to R script
by j1n3l0 (Friar) on Oct 15, 2007 at 21:39 UTC
    Thank you very much! This is precisely what I was looking for =)

    Now I need to tweak it a bit for my needs. Thank you soooooooooo much!


    Smoothie, smoothie, hundre prosent naturlig!
      very late answer, maybe the library is newer than your question, but what about optparse or getopt?
      install.packages('optparse') ?optparse
      I tried to get it working (I come from Python and I'm used to the syntax) but in the end I settled for the easier (and working) 'getopt' solution:
      install.packages('getopt') . . . if(require("getopt", quietly=TRUE)) { opt <- getopt(matrix(c('path', 'p', 1, "character"), ncol=4, byrow=TRUE)) if(!is.null(opt$path)) path <- opt$path }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://645004]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-05-25 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found