args <- cmdArgs()
cat("User command-line arguments used when invoking R:
")
str(args)
# Retrieve command line argument 'n', e.g. '-n 13' or '--n=13'
n <- cmdArg("n", 42L)
printf("Argument n=%d
", n)
# Short version doing the same
n <- cmdArg(n=42L)
printf("Argument n=%d
", n)
Run the code above in your browser using DataLab