0

For example, if my bash command is:

Rscript $wd/scripts/test.R celFiles=$celFiles 

I would like to be able to access this argument in R as such:

args=commandArgs(trailingOnly=T)
args['celFiles']

Sadly, this produces an "NA", while args[1] seems to work.

Thanks in advance.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 1
    You might be interested in https://stackoverflow.com/q/3433603/4550695 – Mikko Marttila Nov 12 '20 at 21:21
  • There are dedicated packages for this task, see linked post, let us know if they do not work for you. – zx8754 Nov 12 '20 at 21:24
  • 1
    Go with `docopt` which is a little newer than the linked post (though it is mentioned) and portable in that the spec is implemented for several languages -- you learn multiple tools at once. Many usage examples for `docopt` among my `littler` examples here: https://github.com/eddelbuettel/littler/tree/master/inst/examples – Dirk Eddelbuettel Nov 12 '20 at 21:32

0 Answers0