I'm creating an HTML output from a .R script with the command rmarkdown::render(input = "my_script.R"). It calls knitr::spin() and successfully produces an HTML output. In that .R file, there is a filtering variable school_level whose value I want to control from the call to render().
I know for an RMarkdown file I'd specify a parameter in the YAML header. But how do I do that for a .R script? I'm not seeing it in guides like the RMarkdown Cookbook.
Say the line I want to modify in my .R script is:
good_data <- my_data %>%
filter(level == school_lvl)
What do I change in my .R script to control the value of school_lvl from the call to rmarkdown::render? Making the value of school_lvl be "Elementary" or "Secondary".