When I make a new markdown file it generates the header based on my input followed by default code that looks like this:
---
title: "Example Report"
author: "segreenb"
date: "7/30/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
...
And so on. What I want is to have the default look like this:
There isn't currently a way to change the default R Markdown template, but there is an existing feature request. You can contribute by voting with an emoji reaction here:
In the meantime, you can create your own templates and have them appear in the templates list within the new document dialog box. It's a bit more involved than one might expect (you need to make a package for the template to live in), but on the upside you'll learn a lot in the process! You can read all the details here:
In RStudio 1.2.1335 on macOS, here's how you can find that file:
In Applications, right-click on RStudio.app and select "Show Package Contents" (application packages are just fancy folders underneath)
A new Finder window opens, and you are inside a folder called "Contents". The default template lives in: Contents/Resources/resources/templates/r_markdown_v2.Rmd
Big Disclaimers:
Since you're editing a file that lives inside the application package, all your changes will disappear the next time you update RStudio. Be prepared to do this all over again each time you update.
You are always at risk of breaking things if you go fishing around inside application packages.
Future updates to RStudio could completely change the way this works, without warning.
I wonder if package ymlthis will be useful for this sort of thing in the long run. It appears you can write both the YAML header and the setup chunk with this package. It's not on CRAN at this point but the GitHub repository is here. I haven't tried it, but it might be worth checking out!
In the introduction vignette section on workflows here it looks like you can put things into your .Rprofile as "an ad-hoc way to make R Markdown templates".