Local Development Setup
R, RStudio, and Quarto on your machine
This guide covers setting up a local development environment. Skip this section if you’re using a Longleaf-only workflow.
Local machines are fine for:
- Writing and editing code
- Small-scale testing
- Manuscript writing
For production analyses (simulations, calibrations, long-running jobs), use Longleaf.
Install R
| Platform | Method |
|---|---|
| macOS | Download from CRAN or brew install r |
| Linux (Ubuntu/Debian) | sudo apt install r-base r-base-dev |
| Linux (Fedora) | sudo dnf install R |
| Windows | Download from CRAN |
Install RStudio (Optional)
Download from posit.co
RStudio provides an integrated development environment with:
- Script editor with syntax highlighting
- Console for interactive R
- Environment browser
- Git integration
- Quarto support
Essential Packages
# Core packages
install.packages(c(
"data.table",
"targets",
"tarchetypes",
"crew",
"here",
"yaml"
))
# For clinical trial work
install.packages(c(
"survival",
"DiceKriging",
"lhs"
))
# For cluster computing (if using crew.cluster)
install.packages("crew.cluster")Local Quarto Setup
Download from quarto.org/docs/get-started
| Platform | Method |
|---|---|
| macOS | Download installer or brew install --cask quarto |
| Linux | Download .deb or .tar.gz from website |
| Windows | Download installer from website |
# Verify installation
quarto --version
quarto checkLaTeX for PDF Output
Quarto can install TinyTeX automatically:
quarto install tinytexThis provides a minimal LaTeX distribution sufficient for most PDF rendering. If you need additional LaTeX packages:
# In R
tinytex::tlmgr_install("package-name")Platform-Specific Notes
Windows
Some packages and workflows have issues on Windows:
- Path separators: Use
here::here()or forward slashes - Line endings: Configure Git to handle (
git config --global core.autocrlf true) - Some packages: May fail to compile (use pre-built binaries when available)
- Parallel computing:
mclapply()doesn’t work; useparLapply()orfuture - Shell scripts: Won’t run natively; use Git Bash or WSL
Recommendation: For serious work, use Longleaf or install WSL 2.
macOS
# Install Xcode command line tools (required for package compilation)
xcode-select --install
# If using Homebrew
brew install r
brew install --cask rstudioThe Xcode command line tools provide compilers needed to install R packages from source.
Linux
Most R packages compile smoothly on Linux. You may need development headers for some packages:
# Ubuntu/Debian
sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev
# Fedora
sudo dnf install libcurl-devel openssl-devel libxml2-develLocal .Rprofile Template
Create or edit ~/.Rprofile on your local machine:
# ~/.Rprofile (local machine)
# Set CRAN mirror
options(repos = c(CRAN = "https://cloud.r-project.org"))
# Useful options
options(
warnPartialMatchDollar = TRUE,
warnPartialMatchArgs = TRUE
)These options help catch common bugs:
warnPartialMatchDollar: Warns when using$with partial column nameswarnPartialMatchArgs: Warns when function arguments are partially matched
Verification
After setup, verify everything works:
R --version
Rscript -e "library(targets); print('OK')"
quarto --version
git --version
gh --version # If you installed GitHub CLIIn R:
# Check essential packages load
library(data.table)
library(targets)
library(here)
# Check Quarto integration
quarto::quarto_version()Syncing with Longleaf
If you develop locally but run on Longleaf:
- Use Git to sync code between machines
- Keep data on Longleaf only (use symlinks for local references)
- Test locally with small subsets
- Run full analyses on Longleaf
See Git & GitHub Setup for version control configuration.
Next: Git & GitHub Setup | Longleaf Setup