I don't know if you can do it directly, but you may be able to approximate it by putting the following in your Rprofile.
make_r_template <- function(filename = "r_template.R", dir = getwd())
{
if (file.exists(file.path(dir, filename))) invisible(NULL)
else{
write(c("##################################################",
"## Project:",
"## Script purpose:",
"## Date:",
"## Author:",
"##################################################"),
file = file.path(dir, filename),
sep = "\n")
}
}
make_r_template()
This will run every time R starts and write the blank template to the working directory, so long as it doesn't exist. You could also run the function at any point with a different filename
value to create a blank template elsewhere.
A nice supplemental touch would be a second function that looks at a file, attempts to identify the header, and inserts it if the header is not found.