Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active October 22, 2020 17:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cderv/5ae7961d25c4e7e9b777 to your computer and use it in GitHub Desktop.
Save cderv/5ae7961d25c4e7e9b777 to your computer and use it in GitHub Desktop.
my custom snippet for RStudio

To insert YAML header for Rnotebook

snippet yaml_notebook_html
	#' ---
	#' title: "${1:title}"
	#' author: "${2:author}"
	#' knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = sprintf("%s_%s.html", format(Sys.Date(), "%y%m%d"), basename(tools::file_path_sans_ext(inputFile))))})
	`r paste("#' date: '\u0060r paste(\u0022", format(Sys.time(), "%d/%m/%Y")," - Dernière MAJ:\u0022, format(Sys.time(), \u0022%d/%m/%Y\u0022))\u0060'", sep = "")`
	#' output : 
	#'    html_document:
	#'       highlight: tango
	#'       theme: united
	#'---

To insert YAML header for Rmd document

snippet yaml_Rmd_html
	---
	title: "${1:title}"
	author: "${2:author}"
	knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = sprintf("%s_%s.html", format(Sys.Date(), "%y%m%d"), basename(tools::file_path_sans_ext(inputFile))))})
	`r paste("date: '\u0060r paste(\u0022", format(Sys.time(), "%d/%m/%Y")," - Dernière MAJ:\u0022, format(Sys.time(), \u0022%d/%m/%Y\u0022))\u0060'", sep = "")`
	output: 
		  html_document: 
				highlight: tango
				theme: united
				toc: $(4:yes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment