Skip to content

Instantly share code, notes, and snippets.

@wjhopper
Created May 16, 2022 11:58
Show Gist options
  • Save wjhopper/fd09de8444531378d99c0c08c7b1f909 to your computer and use it in GitHub Desktop.
Save wjhopper/fd09de8444531378d99c0c08c7b1f909 to your computer and use it in GitHub Desktop.
if (.Platform$OS.type == "windows") {
folder <- file.path(Sys.getenv("AppData"), "RStudio", "templates")
} else {
folder <- "~/.config/rstudio/templates"
}
if (!dir.exists(folder)) { dir.create(folder, recursive = TRUE) }
f <- file(file.path(folder, "default.Rmd") ,"wt")
template_text <- '---
title: "Your Title"
author: "Your Name"
output:
pdf_document:
latex_engine: xelatex
html_document: default
---'
writeLines(template_text, con = f)
close(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment