【问题标题】:Is there a way in knitr to evaluate inline code chunks of other languages?knitr 有没有办法评估其他语言的内联代码块?
【发布时间】:2018-05-28 20:15:59
【问题描述】:

knitr 中,可以在代码块中使用其他语言。例如,我们可以使用:

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

我们可以将R引擎与`r some R code`一起使用

是否可以在内联代码中使用其他语言?

例如,我想做类似`python some code`这样的事情。

谢谢。

【问题讨论】:

  • 现在,没有。将来可能会成为可能(我很久以前收到过拉取请求)。
  • Bonjour Marc-André,这里是使用列表包stackoverflow.com/questions/47414027/…的示例
  • 感谢Yihui Xie您的快速回复。非常感谢。 Cedric,我会尝试使用 listings 包,但它似乎比 knitr 复杂得多。

标签: r latex knitr sweave


【解决方案1】:

使用 `r shell(...)` 评估内联

shell 命令可以是一个 python 脚本,它为内联显示生成输出。你甚至可以传入一个 shell=python3 参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多