cmdArgs | R Documentation |
Simple access to parsed command-line arguments.
cmdArgs(args=NULL, names=NULL, unique=TRUE, ..., .args=NULL)
cmdArg(...)
args |
A named |
names |
A |
unique |
If |
... |
For |
.args |
(advanced/internal) A named |
cmdArgs()
returns a named list
with command-line arguments.
cmdArg()
return the value of the requested command-line argument.
The value of each command-line argument is returned as a character
string, unless an argument share name with ditto in the (optional)
arguments always
and default
in case the retrieved
value is coerced to that of the latter.
Finally, remaining character string command-line arguments are
coerced to numeric
s (via as.numeric
()), if possible,
that is unless the coerced value becomes NA
.
Henrik Bengtsson
Internally, commandArgs
() is used.
args <- cmdArgs()
cat("User command-line arguments used when invoking R:\n")
str(args)
# Retrieve command line argument 'n', e.g. '-n 13' or '--n=13'
n <- cmdArg("n", 42L)
printf("Argument n=%d\n", n)
# Short version doing the same
n <- cmdArg(n=42L)
printf("Argument n=%d\n", n)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.