(reopen) How to pass arguments to bash chunk defined as variables in R?

Hi all,

Would you know if there is any way to pass external variables to the bash chunks?

For example, I have python chunk:

{python}
output_dir = "/Users/Santa/results"

Then I would like to execute something like that:

{bash}
./give_gifts_to_chilren -o ((output_dir))/children_addresses.txt

where ((output_dir)) comes from the python environment.

There was a previous thread How to pass arguments to bash chunk defined as variables in R?, but the response is a bit unrelated, because it is not about how to execute bash commands from R, rather than how to have bash commands as separate chunks

Thank you in advance for your help and time,
Andrei

bash chunk as a engine.opts which allows to pass some options

Those advanced engine are not well documented, but you can find there source code at

Basically a command string is built, and it will be run with system2()

Since knitr there is now a eng_execwhich can be used to create an engine for any command line tool. So you could also use that to create your own bash engine

Hope it helps

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.