6

In knitr it is possible to use other languages in code blocks. For example, we can use:

```{python}
Some python code
```

We can use the R engine inline with `r some R code`

Is it possible to use other languages in inline code?

For example, I would like to do something like this `python some code`.

Thanks.

  • For now, no. It might become possible in the future (I have received a pull request quite a while ago). – Yihui Xie Dec 14 '17 at 23:20
  • Bonjour Marc-André, here is an example of the use of the listings package https://stackoverflow.com/questions/47414027/how-to-create-r-markdown-sections-inside-a-r-code-chunk-with-proper-code-displa/47617773#47617773 – Cedric Dec 15 '17 at 21:14
  • Thanks [Yihui Xie](https://stackoverflow.com/users/559676/yihui-xie) for your quick response. It's much appreciated. [Cedric](https://stackoverflow.com/users/4494862/cedric), I will try to use the listings package but it seems much more complex than knitr. – Marc-André Désautels Dec 18 '17 at 14:51

1 Answers1

4

Evaluate inline with `r shell(...)`

The shell command could be a python script that produces output for inline display. You could even pass in a shell=python3 argument.

J_H
  • 17,926
  • 4
  • 24
  • 44