r-如何生成绘图并将其显示在rnw文件的其他位置



我看到了https://bookdown.org/yihui/rmarkdown-cookbook/fig-chunk.html我想知道如果使用我用knitr编译的pdf格式的.rnw文件,是否有类似的东西。提前感谢您的帮助。

是的,您可以使用相同的技巧。您所需要做的就是在文档中使用正确的语法,即在您的案例中使用LaTeX。以下是您提到的从(R(Markdown到Rnw/LaTeX:的示例的翻译

We generate a plot in this code chunk but do not show it:
<<cars-plot, dev='pdf', fig.show='hide'>>=
plot(cars)
@
After another paragraph, we introduce the plot:
includegraphics{Sexpr{knitr::fig_chunk('cars-plot', 'pdf')}}

最新更新