title: How to pass an element from a title, then passed into a function in R Notebook?
body: <p>I am trying to define an element that appears in the title into a R Notebook that I wish to be automatically embedded, or picked into a function. That is because I have 100 hospitals that I have to produce a report for. Therefore, I want to be effective as possible.</p>
  <p>Here it is. I want to pass the hospital name into the title that I wish later one to be picked by the functions made by myself.</p>
  <p>Here is an example of the notebook I have in R:</p>
  <p><a href="https://i.stack.imgur.com/w7Dic.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w7Dic.png" alt="enter image description here" /></a></p>
  <p>And here is the function I have in one of the chuncks:</p>
  <p><a href="https://i.stack.imgur.com/Xd0vh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xd0vh.png" alt="enter image description here" /></a></p>
  <p>One of my parameters in the function I have is <code>hospital_name</code>. I want the hospital name to be appearing first, in the beginning of the R Notebook section, after title as I will have the title and then the hospital name. But then the same parameter, hospital_name that I am hoping to appear after the title, should be automatically picked by my function so that the analysis are done. Is there a way to do this in R Notebook?</p>
  <p>And this is my code:</p>
  <pre><code>---
  title: &quot; Project&quot;
  author: &quot; secret :) &quot;
  date: &quot;`r format(Sys.Date(), '%b %d, %Y')`&quot;
  output:
    pdf_document:
      toc: true
      number_sections: true
    rmarkdown::html_vignette: default
  subtitle: Process Measure Report
  vignette: |
    %\VignetteIndexEntry{Vignette Title} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8}
  ---
  
  ```{r setup, include=FALSE}
  
  knitr::opts_chunk$set(
    collapse = TRUE,
    comment = &quot;#&gt;&quot;,
    echo = FALSE,
    warning = FALSE,
    message = FALSE
    
  )
  
  library(magrittr)
  
  
  ```
  
  
  ```{r}
  # choose dates intervals for the analysis and the hospital name 
  
  start_date &lt;- as.Date('2020-04-01', tz = 'Europe/London')
  end_date &lt;- as.Date('2021-03-31', tz = 'Europe/London')
  hospital_name &lt;- 'Whiston Hospital'
  
  ```
  
  
  in the function appears the hospital_name:
  
  
  ```{r method_admission_initial_diagnosis, echo=F, results='asis', fig.height=5, fig.width=7, cache=TRUE }
  
  method_admission_initial_diagnosis &lt;- 
    mnp::method_admission_initial_diagnosis(data = mnp_std, hospital = hospital_name, start_datetime = start_date, end_datetime = end_date, plot_function = FALSE)
  
  knitr::kable(method_admission_initial_diagnosis, 
               caption = &quot;Number of patients by method of admission and initial diagnosis&quot;)
  
  
  ```
  </code></pre>