Something like this, but it doesn't work:
```{r examples, engine="bash"}
export EXAMPLES="example/path"
```
```{r example1, engine="bash"}
echo $EXAMPLES
```
This works, however:
```{r examples2, engine="bash"}
export EXAMPLES="example/path"
echo $EXAMPLES
```
That is a great question! It is also something I really want to accomplish but do not know how to do it (I appreciate if anybody can help me). It is not only useful for bash
, but also for all other engines in knitr
like python
, ruby
and so on. The reason that it does not work at the moment is knitr
just runs the code via system('engine -arg code')
, i.e. for each code chunk, a new engine session is opened, so all chunks are essentially executed in different processes.
Ideally I want an engine that opens a session and keeps on listening to new code, but I'm not sure if that is possible at all. AFAIK, the only way to share variables is to write them into files, which is obviously awkward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With