I am using params in Rmarkdown. However when using params and making sure everything works, I reconstruct params as a list in my global env and run the document chunk by chunk to make sure it is creating the correct report. I ran across an issue where the params in the yaml was overwriting my list in my global environment. if you run the first chunk without knitting it will createa the params list with the value being 6. then if you run the second chunk (ctrl + shift +enter) it will run the whole chunk. BUT it will overwrite the params list with the default value in the yaml. However when I run it line by line (ctrl + enter) this issue does not happen. What is happening when I run ctrl +shift +enter that is make the list being overwritten?
---
title: "test"
author: "Michael"
output: html_document
params:
id: "4"
---
```{r setup, include=TRUE}
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE,
warning = FALSE
)
params <- list(id = 6)
```
```{r}
library(dplyr)
mtcars %>%
filter(cyl == params$id)
```