I would like to change the default Rmarkdown document template file. Whenever I start a new document it contains this text that describes how to build a plot etc.. It was very helpful in the beginning, but now I would much rather have a clean document with prewritten text to load the libraries I always use (e.g., library(tidyverse) and library(here)) and the HTML settings I prefer.
As I understand Chapter 17 in Rmarkdown: the definitive guide I could create a new template. However, that requires building a package, and also I am really looking to change the default document and not to create a new template.
I have been unsuccessful in finding any guides on this.
Is there a way to change the Rmarkdown Document template?
Since RStudio 1.3 you can create document templates for all supported file types.
Create a template in ~/.config/rstudio/templates/default.R (macOS/Linux) or AppData/Roaming/RStudio/templates/default.R (Windows) to try it out. It works with other file types, too; for example creating a file named default.cpp will set the content for new C++ files.
I am now much closer to a solution that I am happy with. However, I am having difficulties changing the default HTML code at the top of new documents. As far as I can see the top HTML part of a new .Rmd document is not dictated by the document.Rmd template file.
To be more specific, I would like my HTML documents to always include these lines at the top
I can add the lines to a document.Rmd template file, and then delete the abundant code in the new document.
E.g., this code at top of my template document.Rmd file