getArgs: getArgs

Description Usage Arguments Details Value Author(s)

View source: R/getArgs.R

Description

commandArgs parsing

Usage

1
getArgs(defaults = NULL, verbose = FALSE, numeric = NULL)

Arguments

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

Details

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

Value

a named list

Author(s)

Chris Wallace


chr1swallace/random-functions documentation built on Oct. 6, 2017, 11:50 a.m.