I've been using R since before its official first release but don't have a lot of knowledge of R Studio's "bells and whistles." One thing I was trying to do in R Studio is the following: I want to write a function (or use some other functionality possibly available in R Studio) that when run, returns source code to the source code editing window in R Studio at the point where the function is called. This is sort of like an alias, perhaps for a longer block of code. For example if I have some R code like this:
insertCode("John Smith", "August 23, 2020")
library(tidyverse)
and I execute the first line—or even better, after I type the line and press return, tab or some other character—I'd like R Studio to return some templated code to the window and replace the function (or alternatively place it below my insertCode function call). In this example, I was thinking the code, when executed or typed, would replace the line insertCode("John Smith", "August 23, 2020") with program description text so that the following would appear in my source code editor:
###############################################
Author: John Smith
Last Modified: August 23, 2020
###############################################
library(tidyverse)
I realize I could just save a template of source code and open it up any time I need to do this, but I have other ideas of how I'd like to use this functionality too besides inserting program description headers into my code. Is this possible somehow?
Thanks in advance for your assistance.