How to knit a file using the console?

How can knit the following to PDF using a function call?

---
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')) 
```

I thought rmarkdown::render('filename.Rmd') would work, but I get an error, while it works when using the knit button in RStudio. Thus I was wondering if there are any differences between pressing the knit button and using render .

When I use render() I get this error message:

/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.


No, there is not, at least not in general, and I have processed dozens of documents with this little script render.r which is part of littler. It really is just a wrapper around rmarkdown::render() picking up the filename(s) as argument(s). You could just do
Rscript -e 'rmarkdown::render("yourfile.Rmd")'
as well.

It also works with your example provided I fix the error that is flagged, ie the wrong argument "condensed" for latex_options which appears to no longer be valid. I picked "striped" and got this two-page report:

在这里输入图像描述

If you tweak the table and/or suppress the code you can probably make it a one-pager as desired.

链接地址: http://www.djcxy.com/p/33484.html

上一篇: 你如何重命名一个Git标签?

下一篇: 如何使用控制台编织文件?