Skip to contents

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.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("CU-Anschutz-DOS-CORP/startProject")
library(startProject)  

Initial directory creation

You can create a project directory with startProject() or by launching a local Shiny App included in the package.

startProject()

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.title = "Example of startProject function"
  proj.id = "TestRProject", 
  start.date = format(Sys.Date(), "%B %d, %Y"), 
  version = "1", 
  client = "John Smith",
  client.dept = "Testing Department", 
  main.statistician = "Rocio Lopez", 
  structure = "snapshot"
  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 will look like this:

Legacy Structure

[Project_Root]/
├── communications
├── data                       <-- .sas7bdat and .rds work files
├── graphs                     <-- PDF/PNG visual outputs
├── memo                       <-- Written report for PI
├── orig_data                  <-- Specific data pull/Chart review data
├── others
├── r                          <-- R code files
├── temp
│
└── sas                        <-- SAS code files
    └── _include/              <-- <-- Project-specific SAS Macros, functions, etc.

Snap Shot Structure

[Project_Root]/
├── [Study_Name].Rproj          <-- If using R Projects
├── 00_protocol_and_irb/        <-- IRB, DUA, and Study Protocol
├── 01_data_specs/              <-- Data dictionaries and coding crosswalks
├── 02_docs/                    <-- Your structural definitions and project logic
├── 03_include/                 <-- Project-specific SAS Macros, R Functions, and Formats
├── 04_manuscript/              <-- Drafts and reviewer responses
├── 05_presentations/           <-- Conference slides and posters
├── 06_external_resources/      <-- Relevant literature docs
├── README.md                   <-- Master Project Guide
│
└── analysis_2026-04-27/        <-- Version 1 (V1)
    ├── orig_data/              <-- Specific data pull/Chart review data
    ├── code/                   <-- 00_setup.sas, 01_clean.sas, 02_viz.R
    ├── data/                   <-- .sas7bdat and .rds work files
    ├── output_raw/             <-- Unedited output and tables
    ├── graphs/                 <-- PDF/PNG visual outputs
    ├── final_styled/           <-- Manually edited/formatted results
    └── memo/                   <-- Written report for PI

The project information (client, author, etc.) and template details (purpose, notes) are used to populate the templates.

shinyApp

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.

Customize templates

The package may utilize several document templates which can be customized:

  1. memoTemplate.docx
  2. basefile.R, if layout = “single”
  3. multi_setup_basefile.R, multi_data_management_baserfile.R, and multi_analysis_basefile.R, if layout = “multi”
  4. basefile.Rmd
  5. basefile.sas, if layout = “single”
  6. multi_setup_basefile.sas, multi_data_management_baserfile.sas, and multi_analysis_basefile.sas, if layout = “multi”
  7. basefile.md, if structure = “snapshot”

To use customized templates you can either modify those included or save copies on your home directory (details below).

Memo template

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
staffInfo

Code templates

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 (e.g., .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.

Managing included template files

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.