Hello everyone, I would like to give my pdf file a dynamic file name. I already found out that you can name it after the current Sys.Date(), but naming the file after the data being processed in the script is somehow not possible.. Although the document title can be named dynamically by just creating a second YAML section below the R code chunk, where the data is being processed. It does not work with the output file name.
The dynamic title is working fine. But my code to name my file dynamically after the nrows of the given dataframe does not work and is just ignored. Is there any solution to this problem?
---
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
x<-as.data.frame(c(3,4,5))
---
title: "An analysis of `r nrow(x)` cars"
knit: (function(inputFile, encoding) {rmarkdown::render("try.Rmd", output_file=paste("report-", nrow(x), ".pdf", sep=""))})
---
Thank you so much in advance.