Skip to content

mattocci27/quarto-targets-template

Repository files navigation

License: MIT

Disclaimer: This is not a minimal example.

Template for a reproducible R project with Quarto and {targets}

This is an example of a {targets} workflow that runs Bayesian analyses and rendering a manuscript using Quarto. R/functions.R contains some utility functions that are often used in my workflow. ms/manuscript.qmd contains examples of cross-referencing and parameterized texts.

Requirements for running this demo

Option 1: running on local

  • R (>= 4.0.0)

  • Quarto: An open-source scientific and technical publishing system built on Pandoc

  • cmdstan: The shell interface to Stan

  • TinyTeX: A lightweight, cross-platform, portable, and easy-to-maintain LaTeX distribution based on TeX Live

  • renv: A dependency management toolkit for R

Option 2: running on an Apptainer/Singularity container (Linux only)

Usage

Running code on local

To run analysis:

# To install R packages for the first run
# Rscript -e "renv::restore()"

run Rscript

To generate the manuscript:

make

Currently, it is easier to separate Quarto rendering from a {targets} workflow. See Quarto targets - indicate code chunk that causes error #99

Running code in Apptainer (Linux)

To build Apptainer containers:

sudo apptainer build radian.sif radian.def
apptainer exec --env RENV_PATHS_CACHE=/home/${USER}/renv \
	--env RENV_PATHS_PREFIX_AUTO=TRUE \
	radian.sif Rscript -e "renv::restore()"

To run analysis:

apptainer exec --env RENV_PATHS_CACHE=/home/${USER}/renv \
	--env RENV_PATHS_PREFIX_AUTO=TRUE \
	radian.sif Rscript run.R

.Renviron is ignored in git. It is useful to add the following information to .Renviron to use {renv} caches on Linux.

#renv settings
RENV_PATHS_PREFIX_AUTO=TRUE
RENV_PATHS_CACHE=/home/${USER}/renv

Optional

You can also generate Rd files under man/ by running roxygen2::roxygenise().

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published