Summary

  • R packages should be made for better storage, communication, and sharing of code and analyses

When organizing your analyses for a research project, it’s important to maximize two aspects: reproducibility and ease of sharing. This will make the life of your collaborators, and crucially the life of “future you”, much easier. R packages provide a great tool to create collaborative and reproducible code. An R package bundles together the data your project requires, custom-made functions that can be used throughout your code, vignettes that describe your analyses step-by-step, and a thorough documentation that helps you and others to reproduce your analyses in the future. In practice, creating an R package boils down to:

  1. organizing your project folders and files in a clever and consistent way
  2. documenting thoroughly your steps and the tools you use.

Create a R Package

\[\underline{UNDER \space CONSTRUCTION}\]


Build and Call the Package

Once you have populated your package (even just a little), you are ready to build it. This can be done directly from RStudio, inside the R project containing your package. If this is your first package even, go to Build > Configure Build Tools… Here you should tick the checkbox Generate documentation with Roxygen and then tick Build & Reload in the window this prompts. You can now build your package. Go to Build > Build and Reload (or Clean and Rebuild, depending on the version). This will build your package and install it. You can now load it using library(packagename) and start calling your functions.


Working with a R Package

- FunctionsUNDER CONSTRUCTION

- VignettesUNDER CONSTRUCTION

- Sharing with a WebsiteUNDER CONSTRUCTION

- Using GitUNDER CONSTRUCTION



  1. Temple University, ↩︎

  2. Temple University, ↩︎

  3. Temple University, ↩︎

  4. Temple University, ↩︎