```sh
module purge # unload loaded modules to avoid conflict
module load anaconda3/2021.11 # to load libraries like xml2 (required for tidyverse etc.)
module load gcc/11.2.0 # ensure latest compilers are used for package installation
module load R/4.1.0
# launch R and install packages
R
install.packages("tidyverse")
```
# Install brms, rstan, and related libraries
Configure C++ toolchain
```r
# run in R
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC",
"CXX14=g++", # or clang++ but you may need a version postfix
file = M, sep = "\n", append = TRUE)
```
```r
Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")
install.packages("rstan")
install.packages("brms")
```
# Resources
- [RStan Getting Started · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)
- [Configuring C Toolchain for Linux · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/Configuring-C-Toolchain-for-Linux)