required_pkgs <- c(
"shiny", "shinycssloaders", "dplyr", "tidyr", "DT",
"terra", "geodata", "rpart", "rpart.plot", "randomForest",
"pROC", "FNN", "rgbif", "neotoma2", "pastclim"
)
new_pkgs <- required_pkgs[!(required_pkgs %in% installed.packages()[, "Package"])]
if (length(new_pkgs) > 0) {
install.packages(new_pkgs, dependencies = TRUE)
}
message("All required packages are installed and ready!")Quickstart Guide: North American Pinus Ecological Niche & Climate Projection Suite
Installation, Package Setup, Data Architecture, and Application Launch
1. Download and Install R and RStudio
Before launching the modeling modules, install R (the statistical computing engine) and RStudio Desktop (the integrated development environment):
- Install R (Version 4.3+):
- Visit the Comprehensive R Archive Network (CRAN) at https://cran.r-project.org/.
- Select your operating system (Download R for Windows, macOS, or Linux) and run the installer using default settings.
- Install RStudio Desktop:
- Visit Posit at https://posit.co/download/rstudio-desktop/.
- Download and install the free RStudio Desktop installer for your operating system.
2. One-Time Package Installation
Open RStudio, click into the Console pane, paste the following one-time setup script, and press Enter to install all required spatial, paleoclimate, and machine learning packages:
3. Downloading the Project Folder & Launching the Apps
- Download & Extract the Project Folder:
- Download the course project
.ziparchive and extract (unzip) it to a permanent folder on your computer (e.g.,Documents/pines/). - Verify that the
data/subfolder is located directly inside the project directory alongsidepinus_app1.R,pinus_app2.R,pinus_app3.R, andpinus_app4.R.
- Download the course project
- Launch Any Module in RStudio:
- Open RStudio and go to File -> Open File… to open
pinus_app1.R(or Modules 2, 3, or 4). - Set your working directory to the project folder via Session -> Set Working Directory -> To Source File Location.
- Click the green Run App button in the top-right corner of the script editor.
- Open RStudio and go to File -> Open File… to open
4. Data Sources & Processing Architecture
All spatial layers are standardized to the North American Albers Equal Area Conic projection with a central meridian at 100o West (NAD83, units in meters):
- Taxonomic Hierarchy (The Gymnosperm Database): Subgeneric, sectional (P. sect. Pinus, P. sect. Trifoliae, P. sect. Quinquefoliae, P. sect. Parrya), and subsectional classifications follow Christopher J. Earle’s The Gymnosperm Database (https://www.conifers.org/pi/Pinus.php).
- Occurrence Records & Biome Outgroups (GBIF): Georeferenced occurrences for native North American Pinus species and six widespread biome anchor species (Larrea tridentata, Artemisia tridentata, Betula nana, Bouteloua gracilis, Adenostoma fasciculatum, and Acer saccharum) were retrieved via
rgbif::occ_download(). Records were thinned to unique 1 km grid cells and filtered using a 3rd-nearest-neighbor (\(\le 100\text{ km}\)) spatial outlier rule to remove cultivated plantings and geocoding errors. - Late 20th Century Climate Normal (1970–2000 CE) & Topographic Ruggedness (WorldClim 2.1): Seventeen shared bioclimatic variables (
BIO1,BIO4–BIO19) and the Terrain Ruggedness Index (TRI) were extracted at 1 km resolution to train models across steep montane gradients. For continental map projections, Bioclim layers were aggregated to 5 km using the pixel mean, whileTRIwas aggregated to 5 km using the pixel maximum to preserve canyon and sky-island ruggedness. - Quaternary Paleoclimate Reconstructions (Beyer2020 via
pastclim): Hindcast grids at 5 km resolution span the Last Glacial Maximum (~21,000 BP) and the three formal IUGS Holocene stages: Greenlandian (11,700–8,300 BP), Northgrippian (8,300–4,200 BP), and Meghalayan (4,200–0 BP). - 21st-Century Climate Forecasts (CMIP6 MRI-ESM2-0): Projected 5 km grids cover Early Century (2021–2040), Mid-Century (2041–2060), and Late-Century (2081–2100) under moderate (SSP2-4.5) and high-emissions (SSP5-8.5) scenarios.
- Fossil Packrat Middens & Macrofossils (Neotoma Paleoecology Database): Retrieved via
neotoma2across the Late Pleistocene and Holocene (0–50,000 cal yr BP) for independent paleo-validation. - Wildfire Perimeters (USGS/USFS MTBS) & Bark Beetles (Dendroctonus & Ips): National Monitoring Trends in Burn Severity (MTBS) fire perimeters (
1985–present) and GBIF bark beetle detections (1975–present) were aggregated into 5-year time slices on the 5 km Albers grid to evaluate disturbance exposure across shifting pine ranges.