Equivalent to \ Sexpr {} for Python, etc. In knitr + RMarkdown?

In R Markdown, I can set the object in the R code snippet and then have the value of this object in the body of my document, for example:

```{r} TMP<-"Blue" TMP ``` The sky is `r TMP` 

The result of this in my compiled PDF is as follows:

 TMP<-"Blue" TMP ## [1] "Blue" The sky is Blue 

This feature is incredibly useful. However, I do not want to limit myself to using it exclusively with R-code. I would like to be able to set objects in pieces of code using other languages, and then call their values ​​in the text in the same way.

RMarkdown + knitr does an excellent job of writing and compiling these pieces of code in other languages, but I find no way to call the values ​​of these objects in the text of the document in the same way as this format in RMarkdown or the \ Sexpr {} function from LaTeX . I am open to using a different documentation system for this, if it is easier. I have seen questions like, but this is just not useful, because the scripts that I will use are much longer and more complicated than small one-line ones.

Here is a complete RMarkdown document that details current behavior with R, and desired (same) behavior with Python, etc.


 title: "SAMPLE" author: "me" date: "September 21, 2015" output: pdf_document: keep_tex: yes --- ```{r} TMP<-"Blue" TMP ``` You can insert the value of an object created with an R code chunk into text like this: The sky is `r TMP` ```{r,engine='python'} COLOR = "red" print COLOR ``` You cannot do the same thing with Python, or other types of code: The car is `python COLOR` 
+6
source share

All Articles