Repository for the paper Halbritter et al. (submitted) Effects of warming, nitrogen, and grazing on plant functional traits differ between alpine and sub-alpine grasslands.
This is the README file for the repository associated with the paper Halbritter et al. (submitted) Effects of warming, nitrogen, and grazing on plant functional traits differ between alpine and sub-alpine grasslands.
### Reproducible Analysis Pipeline
This project uses the R packages renv and targets to ensure fully reproducible analyses. This README explains how to set up your environment, install dependencies, and run the analysis pipeline on any major platform.
- renv: Manages R package dependencies in a project-local library, ensuring reproducibility.
- targets: Orchestrates the analysis pipeline, making workflows reproducible and scalable.
- macOS (Intel/x86_64 or Apple Silicon/arm64)
- Linux (Debian/Ubuntu, Fedora, etc.)
- Windows
The following system libraries must be installed before restoring the R environment:
- OpenSSL
- freetype
- harfbuzz
- fribidi
- libtiff
- jpeg
- pkg-config (for compiling R packages)
- A C/C++ compiler toolchain (e.g., Xcode Command Line Tools, build-essential, Rtools)
-
macOS:
- Install Homebrew
- Install libraries:
brew install pkg-config openssl freetype harfbuzz fribidi libtiff jpeg
- If using Intel/x86_64 R on Apple Silicon, prefix with
arch -x86_64as needed.
-
Linux (Debian/Ubuntu):
sudo apt-get update sudo apt-get install build-essential pkg-config libssl-dev libfreetype6-dev libharfbuzz-dev libfribidi-dev libtiff5-dev libjpeg-dev
-
Linux (Fedora/RedHat):
sudo dnf install @development-tools pkgconf-pkg-config openssl-devel freetype-devel harfbuzz-devel fribidi-devel libtiff-devel libjpeg-devel
-
Windows:
- Install Rtools for compilation.
- Most dependencies are available as binary packages from CRAN. If you encounter errors, install the corresponding system libraries or use precompiled binaries.
Note: Ensure that the system libraries are available for the architecture matching your R installation (e.g., x86_64 or arm64).
A project-local .Renviron file may be provided to help R find the correct system libraries. If you need to recreate it, add the following lines to .Renviron in the project root, adjusting paths for your platform:
PKG_CONFIG_PATH="/path/to/openssl/pkgconfig:/path/to/freetype/pkgconfig:/path/to/harfbuzz/pkgconfig:/path/to/fribidi/pkgconfig:/path/to/libtiff/pkgconfig:/path/to/jpeg/pkgconfig"
PATH="/path/to/openssl/bin:${PATH}"
- On macOS with Homebrew, the default is
/usr/local/opt/<package>/lib/pkgconfig(Intel) or/opt/homebrew/opt/<package>/lib/pkgconfig(Apple Silicon). - On Linux, use
/usr/lib/x86_64-linux-gnu/pkgconfigor similar. - On Windows, this is usually not needed if using binary packages.
After editing .Renviron, restart your R session.
- Clone the repository and open the project in RStudio or your preferred R environment.
- Install renv (if not already installed):
install.packages("renv") - Restore the project library:
This will install all required R packages as specified in
renv::restore()
renv.lock.
- Install targets (if not already installed):
install.packages("targets") - Run the pipeline:
This will execute the workflow as defined in your
targets::tar_make()
_targets.Rfile and any supporting scripts in theR/directory.
- If you encounter errors about missing system libraries (e.g., OpenSSL, freetype, harfbuzz, fribidi, libtiff, jpeg), ensure you have installed the correct versions for your platform and architecture, and that your
PKG_CONFIG_PATHis set up as above. - If you see errors about package versions or missing packages, run
renv::status()to diagnose andrenv::snapshot()to update the lockfile if needed. - For custom or GitHub packages, install them as needed (e.g.,
remotes::install_github("audhalbritter/dataDocumentation")) and then runrenv::snapshot().
- All R package dependencies are tracked in
renv.lock. - All system-level dependencies are listed above.
- The analysis pipeline is fully reproducible using the
targetsworkflow.
- macOS: If using Apple Silicon, you may need to use Intel (x86_64) versions of R and Homebrew for compatibility with some packages. Use
arch -x86_64as a prefix for commands if needed. - Linux: Package names may vary by distribution; consult your package manager's documentation if you encounter issues.
- Windows: Most dependencies are available as precompiled binaries. If you encounter compilation errors, ensure Rtools is installed and on your PATH.
For questions or issues, please contact the project maintainer or open an issue in the repository.