However, nothing except for params$year$value seems to be passed to the main body of the report.
Knitting the following shows that only the value is in the params list, but none of the other entries are available. Note the final missing back tick in the Rmarkdown code if copy/pasting to RStudio
Hi @dromano
Of course. I have a R markdown document setup to read in a few files and write some language based on a few inputs. It works as is, but I just want to organize my yaml differently.
Example that works:
---
title: My Document
output: html_document
params:
file1: "file1.csv"
file2: "file2.csv"
var1: 2020
var2: "January"
---
<!--```{r}
#x <- read.csv(params$file1)
#y <- read.csv(params$file2)
# do stuff with x and y
```-->
A paragraph using `r params$var1` and `r params$var2`.
Again, mainly I want to organize the yaml in a nested form, but the following does not work, even though it is valid yaml.
---
title: My Document
output: html_document
params:
files:
file1: "file1.csv"
file2: "file2.csv"
vars:
var1: 2020
var2: "January"
---
<!--```{r}
#x <- read.csv(params$file1)
#y <- read.csv(params$file2)
# do stuff with x and y
```-->
A paragraph using `r params$vars$var1` and `r params$vars$var2`.
If you fix that missing ` and comment out reading in the files that don't exist, you get the following error:
Error: no value field specified for YAML parameter 'files'
Execution halted
Thanks, @r_alanb: I can't get your working example to work without adding the missing `, so I'm little puzzled trying to understand why it works for you. Could you confirm that copying and pasting it into a new .Rmd file works for you, too?
Thanks for your time helping @dromano. It did work for me if I added the back tick and commented out the read.csv() lines. So I've gone ahead and commented out the entire R code block so it should work with a straight copy/paste.
I see, and sorry to have misunderstood: I'd love to know where to find the code responsible for making the parameters available, but I'm pretty sure debug() won't be any help. I'll keep an eye out, though, to see if any light gets shed on the question...