Similarly to this question, I want to use a R object into a YAML header using R Markdown
and knitr
.
The difference in my case is that the R object (year
, a numeric) is not generated with the Rmd file, but already exists before the Rmd "knitting". Thus, I load a Rdata where this object is stored, and then write the YAML header. The top of my Rmd file looks like this:
```{r global_options, echo=FALSE, warning=FALSE}
load('\\\\folder/MyData.Rdata')
knitr::opts_chunk$set(fig.width=15, fig.height=8)
```
---
title : "Analysis for year `r year`"
author : "Dric"
output : pdf_document
---
After knitting, the document is successfully created, with a correct title, but into HTML format, not PDF. How can I create a PDF file in my case?