Run RMarkdown with arguments on the command line

前端 未结 1 1521
醉话见心
醉话见心 2021-02-20 01:49

I\'m trying to run a Rmarkdown file (myfile.Rmd) from the command line terminal. This file needs to take an argument to work. We can use this simple file as an exam

相关标签:
1条回答
  • 2021-02-20 02:17

    Adding the myarg object as a parameter is the way to go:

    Rscript -e "rmarkdown::render('example.Rmd',params=list(args = myarg))"

    And then add the parameter to your Rmd file:

    ---
    title: "Simple example"
    output:
      pdf_document: default
    params:
      args: myarg
    ---
    

    Documentation on parameterized reports here: https://rmarkdown.rstudio.com/developer_parameterized_reports.html

    0 讨论(0)
提交回复
热议问题