Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way in knitr to evaluate inline code chunks of other languages?

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.

like image 644
Marc-André Désautels Avatar asked Dec 14 '17 16:12

Marc-André Désautels


People also ask

What does echo false mean?

Chunk options The initial line in a code chunk may include various options. For example, echo=FALSE indicates that the code will not be shown in the final document (though any results/output would still be displayed).

How does adding code chunks improve the usability of your R markdown file?

Code Chunk Options You can add options to each code chunk. These options allow you to customize how or if you want code to be processed or appear on the rendered output (pdf document, html document, etc). Code chunk options are added on the first line of a code chunk after the name, within the curly brackets.

Which symbols define an R code chunk in R markdown?

A code chunk usually starts with ```{} and ends with ``` . You can write any number of lines of code in it. Inline R code is embedded in the narratives of the document using the syntax `r ` .


1 Answers

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.

like image 127
J_H Avatar answered Sep 24 '22 20:09

J_H