'Dynamically naming the output file in a custom R-markdown function

I found the function below here. It works great, but I would like to dynamically name the output file 'analysis.docx', using the title of the document, the author and the current date.

title: thetitle
author: myinititals
date: "`r Sys.Date()`"
knit: (function(inputFile, encoding) { 
          out_dir <- 'test';
          rmarkdown::render(inputFile,
                            encoding=encoding, 
                            output_file=file.path(dirname(inputFile), out_dir, 'analysis.docx')) })

How do I make 'analysis.docx' dynamic in this case?

I found some more information here, but not my desired answer.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source