RStudio Code Snippets are text macros that are used for quickly inserting common snippets of code.
If you're not already familiar, here's Mara's walk-through. You can set these up for R, Markdown, Python, Stan, and other langauages and markups
You can also run R code in your snippet. Use `
r expr` anywhere in your snippet; your R code will be executed when the snippet is expanded, and the result inserted into the document.
A question came up recently, what if I want my snippet to produce the text `
r expr` without executing the code?
For example, suppose you want a shortcut to an RMarkdown header that with a date that always produces the current date:
r format(Sys.time(), "%Y-%m-%d")`