如何使用控制台编织文件?

How to knit a file using the console?

如何使用函数调用将以下内容编织成 PDF?

---
title: '`r params$college` report'
params:
  college: 'Art & Business'
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = F)
```

```{r}
library(tidyverse)
library(knitr)
library(kableExtra)
```

```{r}
mtcars %>% 
 kable( format = 'latex',  longtable = T, booktabs = T) %>% 
  kable_styling(latex_options = "condensed", font_size = 8) %>% 
  landscape(margin = c('1cm')) 
```

我认为 rmarkdown::render('filename.Rmd') 会工作,但我收到错误,而在 RStudio 中使用编织按钮时它工作。因此我想知道按下编织按钮和使用 render.

之间是否有任何区别

当我使用 render() 时,我收到此错误消息:

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' ! LaTeX Error: Environment landscape undefined.

Error: Failed to compile test.tex. See test.log for more info.

不,没有,至少一般情况下没有,我用这个小脚本处理了几十个文件render.r which is part of littler。它实际上只是 rmarkdown::render() 的包装器,将文件名作为参数。你可以这样做
Rscript -e 'rmarkdown::render("yourfile.Rmd")'
以及。

它也适用于您的示例 前提是我修复了标记的错误,即 latex_options 的错误参数 "condensed" 似乎不再有效。我选择了 "striped" 并得到了这份 two-page 报告:

如果您调整 table and/or 抑制代码,您可能可以根据需要将其设为 one-pager。