Skip to contents

R Analysis Packages are an extension of the standard R package layout designed to support publishing a collection of R notebooks used for data analysis as static html, typically using GitHub Pages.

R Notebooks include a YAML header and R Markdown body. The Analysis Package Layout follows the convention that the first non-blank line in the body of an R notebook serves as a brief description of the work. rdev includes an “Analysis Notebook” RStudio R Markdown template (File > New File > Rmarkdown > From Template) and a README.Rmd template optionally installed with use_analysis_package() that dynamically builds a list of notebooks and descriptions when devtools:build_readme() is run.

The table below documents the complete R Analysis Package layout:

  • Path: Path to the file or directory relative to the package root
  • R: Included in the R package definition
  • g: Stored in git
  • Function: The function of the file or directory
Path R g Function
.Rbuildignore x x Files excluded from the package, sorted using sort_rbuildignore()
.RData Saved workspace - not used
.Rhistory R command history
.Rprofile x x Used by renv and to attach development tools
.Rproj.user RStudio local project files
.git git version control
.github x GitHub templates and workflows
.gitignore x x git exclusions based on GitHub R. Generated files outside of docs (used by GitHub Pages) are excluded.
.lintr x lintr default linters with 100 columns: linters: with_defaults(line_length_linter(100))
DESCRIPTION x x Package metadata. Use “Suggests” for development tools, per renv
LICENSE x x Generated with usethis::use_mit_license()
LICENSE.md x See above, used by pkgdown
NAMESPACE x x Automatically generated with roxygen2
NEWS.md x Release notes, used by pkgdown
R x x All project functions go here, with roxygen2 comments
README.Rmd x x Generated with usethis::use_readme_md() or rdev template
README.md x x Generated with devtools::build_readme()
TODO.md x To-do list, inspired by https://github.com/rstudio/renv/blob/99737730ea69730b211770ba2bfa78301cf0e7b2/TODO.md
_pkgdown.yml x pkgdown metadata, stored in the project root to make it more discoverable
analysis x Exploratory data analysis in R Notebooks and R Presentations. Include functions from the R directory using library(), not source().
analysis/assets x External assets (images, other files) included in R Notebooks
analysis/data x Used to store small data sets used for analysis and exported data as csv files
analysis/import Used for local storage of large data sets
analysis/rendered Manually rendered versions of analysis/ files to be included in docs/, like .Rpres files
demos x Not used, as recommended by R Packages
docs x Used by build_analysis_site() to render the R Package and Notebooks for GitHub Pages
exec x Command line executable scripts - not used
inst x x Installed files: templates and WORDLIST
inst/bin x x Used for shell scripts that support development, like setup-r
inst/rmarkdown/templates x x R Markdown Templates
man x x Automatically generated with roxygen2
package.Rproj x Use the same name for the package, .Rproj, directory, and GitHub repository
pkgdown x Store all pkgdown files here
po x x Used for Internationalization if needed
renv x Used by renv
renv.lock x renv lockfile
tests x x Tests using testthat and spelling
tools x Auxiliary files needed for building packages - not used
vignettes x x Package vignettes and articles, written in R Markdown