Description Usage Arguments Details Value Author(s)
commandArgs parsing
1 |
defaults |
a named list of defaults, optional |
verbose |
print verbage to screen |
numeric |
names of arguments that should be converted from character to numeric, optional |
return a named list of command line arguments
Usage: call the R script thus ./myfile.R –args –myarg=something or R CMD BATCH –args –myarg=something myfile.R
Then in R do myargs <- getArgs() and myargs will be a named list
> str(myargs) List of 2 $ file : chr "myfile.R" $ myarg: chr "something"
To supply a vector as an argument, simply repeat the argument's name:
... –args f=kk f=pp ll
> str(myargs) List of 2 $ f : Named chr [1:2] "kk" "pp" ..- attr(*, "names")= chr [1:2] "f" "f" $ ll: logi TRUE
a named list
Chris Wallace
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.