Passing multiple arguments via command line in R

前端 未结 5 1195
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 07:49

I am trying to pass multiple file path arguments via command line to an Rscript which can then be processed using an arguments parser. Ultimately I would want something like

5条回答
  •  半阙折子戏
    2021-01-06 08:22

    Although it wasn't released on CRAN when this question was asked a beta version of the argparse module is up there now which can do this. It is basically a wrapper around the popular python module of the same name so you need to have a recent version of python installed to use it. See install notes for more info. The basic example included sums an arbitrarily long list of numbers which should not be hard to modify so you can grab an arbitrarily long list of input files.

    > install.packages("argparse")
    > library("argparse")
    > example("ArgumentParser")
    

提交回复
热议问题