我将Rmarkdown与python一起使用。python的R
内联代码的等价物是什么?示例,在https://rmarkdown.rstudio.com/lesson-4.html我可以做
`rx`
在文本中显示x的值。但是如果我做
`python x`
我刚刚得到文本python x
有了这个解决方法,就有可能:
```{r setup, include=FALSE}
library(reticulate)
```
```{python include=FALSE}
result = 1 + 1
```
1 + 1 = `r py$result` # 1 + 1 = 2
其中py$result
的意思是:取名为result
的Python变量的值。
不确定这是否可能。我发现的所有例子都使用R内联代码,比如so'rpy$x'来实现这一点。参见例如rmarkdown食谱。