简体   繁体   中英

rmarkdown render not recognizing parameters

In my R file I have:

library(rmarkdown)

rmarkdown::render("C://Users//me//Desktop//test_param.Rmd", 
                  params = list(region = "west"))

and in the rmd file:

---
title: "test"
output: pdf_document
params:
  name: "test"
---

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

`r params$name`

that rmd works when I run in separately.

BUT when I run the .r file I get this error

Error in knit_params_get(input_lines, params) : 
  render params not declared in YAML: region

what's the reason for this error?

knitr 's override overrides existing params. You need to have a front matter like:

---
title: "test"
output: pdf_document
params:
  name: "test"
  region: ""
---

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM