Introduction to prodigenr

Luke W. Johnston

2019-07-01

Are you an academic researcher who often writes up abstracts for conferences or submits manuscripts to journals? Do you often have to make slides or posters for presentations? Is your usual workflow to copy a previous project and start replacing the old text for the new text? This R package was designed with you in mind!

prodigenr, or project directory generator, simplifies the process of creating these new projects and can help make your workflow more reproducible. Standard files and folders are created for specific projects (e.g. abstracts or manuscripts), along with a workflow that tries to be simple and easy to use, while making use of the infrastructure and processes already well-developed and maintained (e.g. RStudio and devtools).

Because researchers often write or create many papers, slides, posters, and abstracts, it can quickly become tedious and messy to always make a new directory with all the necessary files and organization.

Setting up a project with prodigenr

Starting a research project? Create a project directory like so:

library(prodigenr)
# Create a temporary folder using the fs package
new_project_path <- fs::path_temp("HeartDiseaseExercise")
setup_project(new_project_path)
#> ✔ Created project at '/tmp/Rtmp4QZTUE/HeartDiseaseExercise'
#> ✔ Added 'README.md' files to the 'doc/', 'R/', 'data/', and parent folders
#> ✔ Added some template R scripts to the 'R/' folder
#> ✔ Project placed under Git version control
#> ✔ Project setup has been completed!
#> ● Now open 'HeartDiseaseExercise.Rproj' to get started on the project!

Or via RStudio’s interface (with RStudio version >1.1):

Creating a prodigenr project in RStudio

Creating a prodigenr project in RStudio

The resulting file structure should look something like this:

/tmp/Rtmp4QZTUE/HeartDiseaseExercise
├── DESCRIPTION
├── HeartDiseaseExercise.Rproj
├── R
│   ├── README.md
│   ├── fetch_data.R
│   └── setup.R
├── README.md
├── TODO.md
├── data
│   └── README.md
└── doc
    └── README.md

Ok, now you can open up the newly created R project file (.Rproj). A README.md file is contained within each project and each folder that explains more about what each folder does and what some of the files do that were created. To add the main document type (e.g. poster, manuscript), run any of the create_*() commands (e.g. create_poster()) in the console of the project.

# you need to run these in the project's console
create_abstract()
create_poster()
#> ✔ Creating a 'abstract' file in the 'doc/' folder
#> ✔ Creating a 'poster' file in the 'doc/' folder

Which will now add two more files to the doc/ folder. The resulting file structure should look something like this:

/tmp/Rtmp4QZTUE/HeartDiseaseExercise
├── DESCRIPTION
├── HeartDiseaseExercise.Rproj
├── R
│   ├── README.md
│   ├── fetch_data.R
│   └── setup.R
├── README.md
├── TODO.md
├── data
│   └── README.md
└── doc
    ├── README.md
    ├── abstract.Rmd
    └── poster.Rmd

At present, there are only four template files that you can view using:

template_list
#> [1] "abstract"   "manuscript" "poster"     "slides"

These template files are what an academic researcher likely typically encounters. However, if you have a suggestion or want to add a template, please create a Github issue or submit a Pull Request!

The end goal of each project is to be as self contained as possible. So that if you ever need to go back to the analysis, it is easy to re-run the code and get the results that you say you got. This is especially useful if others such as reviewers ask for something or want to confirm your results. For more information on good practices to use in making an analysis project, see here or here. See the manifesto for more details on the underlying philosophy behind this package (and soon to be others).

Workflow when using projects created from prodigenr

A typical workflow, which is also outlined in the README.md of the created project, would be to:

  1. Write up your analysis and associated written explanations of the results, as you would for any research project, in the abstract, poster, slides, or manuscript .Rmd (R Markdown) file in the doc/ folder.
  2. Any piece of code you use more than once or is fairly complex, convert it into a function. Put this new function into a file (or a functions.R file) in the R/ directory. Load that function using devtools::load_all() (Ctrl-Shift-L).
  3. Fetch and wrangle your data in the R/fetch_data.R. You can access the data using the devtools::load_all() function.
  4. Create more Rmd files in the doc/ folder to add analyses that will supplement the main document or that are exploratory.
  5. Knit the .Rmd file in doc/. You now have your final abstract, poster, slides, or manuscript to use for your research.