'In RMarkdown: Is there a way to refer to YAML parameters within the YAML header itself?
---
params:
region: "UK"
date_week: "28_02_2022"
data_path_prefix: "C:\\Path\\To\\Folder\\"
data_path: `r paste0(params$data_path_prefix, params$date_week, "\\")`
title: "Summary Report: `r params$region`"
output:
html_document:
toc: true
df_print: paged
---
Hi all,
I am writing an RMarkdown report and I'm trying to keep any parameters that need to be manipulated each time the report is ran as parameters in the YAML header. Some parts of the report need to call a "date_week" parameter. Other parts need to call a filepath where the last directory is the date week. I would like to have one parameter for the date_week, and have that passed to my data_path parameter so I only have to change one thing.
Is it possible to do this? The code shown above is my attempt but the R code inserted does not evaluate.
Alternatively, are there other tidy ways to organise the code to achieve what I'm trying to do? e.g. would you define parameters in another file? I'm not sure what the best practises are.
Many thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
