I don't know if you can do this directly, but you can 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 start every time R starts up and writes an empty template to the working directory if it does not exist. You can also run the function at any point with a different value filenameto create an empty template elsewhere.
, , , .