在命令行的报告中包含 R markdown 代码块的输出

Include output from R markdown code chunks in report from command line

我在 Linux 命令行中使用 R,因为我不想安装 R studio。我想生成一个 pdf 报告,其中包括我的所有代码和代码的可读格式输出,如图形和 LaTeX 向量。

我使用 install.packages('package')

安装了 knitr 和 markdown

我使用 library('library')

导入

我正在尝试使用 rmarkdown::render('path',pdf_document)

进行渲染

我的代码块以 ``{r} 开头,但是当我生成报告并显示 pdf 时,它不包括我的代码的任何输出,只包括块。

为了生成包含结果的报告,自述文件的文件扩展名必须是“.Rmd”,而不是“.Rscript”或“.R”