The goal of startProject
is to create a project
directory with sub-folders and document templates (.docx, .R, .Rmd,
.sas). The templates will be populated with project information you
provide. The package also contains a set of functions that allow you to
create additional templates if needed.
You can install the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("CU-Anschutz-DOS-CORP/startProject")
library(startProject)
You can create a project directory with startProject()
or by launching a local Shiny App included in
the package.
startProject()
allows you to input project information
and specify the sub-folders you want included. In addition, you can
request the creation of memo, R, Rmd and/or SAS templates. If any of
these templates are requested, the function will search for memo, rcode,
r, sascode or sas sub-folders to store the corresponding template; if
these are not found, a templates sub-folder will be created.
startProject(
main.dir = Sys.getenv("HOME"),
proj.name = "TestRProject",
proj.num = NULL,
start.date = format(Sys.Date(), "%B %d, %Y"),
version = "1",
client = "John Smith",
client.dept = "Testing Department",
main.statistician = "Rocio Lopez",
stats.collab = NULL
subfolders = "communications, data, graphs, memo, orig_data, others, r, sas",
templates = "memo, R, Rmd, sas",
memo.name = NULL,
memo.re = "Get started with startProject",
r.name = NULL,
r.purpose = "This R file displays the template generated by startProject",
r.notes = NULL,
rmd.name = NULL,
rmd.purpose = "This Rmd file displays the template generated by startProject",
rmd.notes = NULL,
sas.name = NULL,
sas.purpose = "This SAS file displays the template generated by startProject",
sas.notes = NULL)
The directory created looks like this:
Directory Tree
The project information (client, author, etc.) and template details (purpose, notes) are used to populate the templates. The templates created can be viewed here.
If you prefer, you can launch a local Shiny app that will facilitate
using startProject()
. For details on the app and how create
a short cut that allows accessing the startProject app without opening
R, go here.
The package utilizes 4 document templates which can be customized:
To use customized templates you can either modify those included or save copies on your home directory (details below).
The header and layout in memoTemplate.docx can be modified but it is important to not change the names for the placeholders for information passed by the functions (DATESEC, TOSEC, etc.); if you want to omit the information you can delete the placeholder.
You can save your modified template in your home directory
(Sys.getenv("HOME")
) and name it
.basefile.docx (note the . before the filename); this
basefile will override the included template in this and any future
installation of the package.
You can also save a .staffInfo file in your home directory
(Sys.getenv("HOME")
) with your name, email and phone number
to be inserted into the memo footer. Leave the last line blank to avoid
a warning message in R. Your file should look like this:
staffInfo
The headers for the .R, .Rmd and .sas are generated by the
startProject
functions and cannot be changed. You can
append code and comments under the generated header by either creating a
.basefile (.basefile.R, .basefile.Rmd or .basefile.sas)
in your home directory (Sys.getenv("HOME")
) or by modifying
the base file included in the package (instructions on next section); this allows you to add commonly
used code to your templates.
The base files included in the package have a note indicating that you can modify them; If you wish to generate the template(s) with only the header, simply delete the files or clear the current content.
You can physically delete or open and modify any of the template
files included in the package. To find the location of the included
template files, use
system.file("templates", package = "startProject")
. Note
that the names of the files cannot be changed.
Some of these tasks can be done from within your R session.
To delete the .R template file, for example, you can use:
unlink(paste0(system.file("templates", package = "startProject"), "/basefile.R"))
If you already have templates stored in a separate location, you can
move the files using file.copy()
. For example:
file.copy(
"C:/FromDirectory",
system.file("templates", package = "startProject"), overwrite = TRUE)
If the template file has the same name as the package template, this will overwrite the existing template with yours. If your template has a different file name, then you must rename it.
file.rename(
paste0(system.file("templates", package = "startProject"), "/YourTemplateNameHere.R"),
paste0(system.file("templates", package = "startProject"), "/basefile.R"))
This will overwrite the existing template with yours.
It is strongly recommended you have .basefiles in your home directory or store copies of your modified templates in a separate location and use the above functions to move the files into the package directory; this will facilitate package updates.