EA030 — RTricks

Welcome to the RTricks resource hub for EA030. Tutorials, worked examples, and reference materials for R in environmental data analysis — from loading your first dataset through mixed-effects models and spatial analysis. Each card links to a self-contained module. Cards marked coming soon are in progress.

Getting Started

Setup, orientation, and reproducible workflow fundamentals.

💻
R & RStudio Setup
Install R and RStudio, configure your environment, and verify with a test script.

setup

🔧
Introduction to R
R objects, vectors, and data frames from scratch. Arithmetic operators, summary statistics, base-R graphics, and simple linear models — demonstrated with a lake temperature profile case study.

R

📁
Project Structure
Organize scripts, data, and outputs using RStudio Projects and a consistent folder hierarchy.

workflow

🧶
RMarkdown & knitr
Weave prose, code, and output into reproducible reports. YAML headers, chunk options, rendering.

rmarkdown

🗃️
Data Import
Reading CSV, Excel, and field-data files. Handling encoding issues and common pitfalls.

import

Basic Statistics

Descriptive summaries, inference, and foundational visualization.

📊
Descriptive Statistics
Measures of center and spread, frequency tables, base-R and dplyr summaries.

descriptive

📈
Data Visualization
Core ggplot2 grammar: geoms, aesthetics, facets, themes, and export-ready figures.

ggplot2

🗂️
Four Statistical Frameworks
Every statistical test you will encounter in environmental science fits into one of four frameworks determined by a single question: what type of variable is your outcome (dependent), and what type of variable is your predictor (independent)?

inference

📡
Signal over Noise
Every classical statistical test — t-test, ANOVA, regression — is a formalization of the same underlying question: is the pattern I see in my data larger than what I would expect from chance variation alone?

inference

🧪
Hypothesis Testing
t-tests, Wilcoxon tests, proportions tests. Effect sizes, p-values, common misconceptions.

inference

📉
Simple Linear Regression
Fitting, diagnosing, and interpreting OLS models with lm(). Residual plots and leverage.

regression

📦
ANOVA & Group Comparisons
One-way and two-way ANOVA, post-hoc tests, and visualizing group differences.

anova

🔗
Tests for Association
Chi-square, Fisher’s exact, and correlation tests. Choosing the right test for categorical and continuous variables, effect sizes (Cramér’s V, odds ratio, r), and assumption checking.

association

📊
Logistic Regression
Modeling binary outcomes — presence/absence, exceedance, survival — with logistic regression. Odds ratios, ROC curves, and model diagnostics.

logistic

📐
Correlation Analysis
Pearson and Spearman correlation, scatterplot matrices, and interpreting correlation structure.

correlation

Advanced Statistics

Multivariate methods, hierarchical models, and specialist tools for environmental data.

🌿
Multiple Regression & GLMs
Multiple predictors, interactions, model selection (AIC), and GLMs for count and binary data.

glm

🏔️
Mixed-Effects Models
Random intercepts and slopes with lme4. Nested and crossed random effects for field designs.

lme4

✂️
LASSO Regression
Penalized regression for automatic variable selection. Fit, cross-validate, and interpret LASSO models with glmnet on environmental water quality data. Includes ridge and elastic net comparison.

glmnet

✂️
Dealing with Non-Detects
Learn to handle environmental data that instruments can’t fully measure — and why faking it breaks your statistics.

non-detects

📈
Time-Series Analysis
Decomposition, autocorrelation, ARIMA, and sensor-data workflows with lubridate and tsibble.

time-series

⏱️
Survival Analysis
Time-to-event analysis with Kaplan–Meier curves, log-rank tests, and Cox proportional hazards models. Applied to algae growth experiments and right-censored environmental data.

survival

🔁
Bootstrapping & Permutation
Resampling-based inference, confidence intervals, and randomization tests.

resampling

🗺️
Spatial Analysis
Importing shapefiles, CRS transformations, spatial joins, and choropleth maps with sf.

sf / terra

🕸️
Multivariate Ordination
PCA, NMDS, and RDA for community and environmental gradient data using vegan.

vegan

📈
Change Point and Shifting Baseline Analysis
Sequential CUSUM monitoring and breakpoint confidence intervals.

coming soon

Core R Skills

General-purpose, transferable R techniques applicable beyond EA030.

🔄
Functional Programming
for loops, the base-R apply family (lapply, sapply, vapply, mapply), and purrr::map() compared side-by-side. Replace repetitive loops with cleaner, type-safe pipelines.

purrr

🔧
Tidyverse Data Wrangling
dplyr verbs, tidyr pivoting, and pipe-based workflows for cleaning field and lab data.

tidyverse

📋
Tables & Reporting
Publication-quality tables with kableExtra, gt, and flextable. Inline R in RMarkdown.

reporting

🐙
Git & GitHub for R
Version-control basics, committing from RStudio, branching, and submitting via pull request.

git

📦
Package Management with renv
Lock package versions and share reproducible environments across machines.

renv

🚧
Sort through R Error Headaches
Decode common R error messages, trace the source of warnings, and build a systematic debugging strategy.

debugging

📅
Dealing with Dates
Parse, manipulate, and plot date-time data with lubridate. Covers POSIXct vs Date, time zones, floor_date(), and sensor timestamp correction.

lubridate

EA030 Field & Lab Activities

Course-specific modules tied to EA030 assignments, field campaigns, and shared datasets.

🗂️
Activity Index
Overview of all EA030 projects this semester — Regional Climate Trends, pHake Lake, Compost Maturity, Inland Empire Air Quality, and Surface Water Quality.

index

💧
Glassware Precision
Quantifying measurement uncertainty in volumetric glassware. Repeated weighing trials, propagation of error, and reporting precision in lab notebooks.

coming soon

💨
Analyzing EPA PM2.5 Data
Thirty years of daily fine particulate matter (PM2.5) for a US county. Download EPA AQS data, clean monitoring records, visualize long-term trends, compute monthly means with 95% CIs by decade, and evaluate exceedances of the 24-hr NAAQS (35 µg/m³). Includes environmental justice discussion.

air quality

🫁
Urban Air Quality: Low-Cost Sensors
Deploy Raspberry Pi + Enviro+ sensors to monitor PM1/PM2.5/PM10 across campus. Covers clock-correction for RTC-less Pis, QC, diurnal patterns, Wilcoxon/Kruskal-Wallis tests, OLS regression, and mixed-effects models (lmer + nlme AR(1)) to handle pseudoreplication and temporal autocorrelation.

air quality

🌱
Testing Compost Maturity
Use Solvita paddle tests to measure compost stability via CO₂ and NH₃ emissions. Import class data, visualise maturity scores across treatments, and apply t-tests, one-way ANOVA, and Tukey HSD to compare compost recipes. Includes assumption checking and a non-parametric Kruskal-Wallis alternative.

soil / compost

🌱
Soil Carbon Analysis
Importing and cleaning soil survey data, fitting depth profiles, and comparing land-use treatments.

soils

💧
pHake Lake Stratification
Seasonal temperature and dissolved-oxygen profiles in a small lake. Thermocline detection, Schmidt stability index, and comparison of stratification across years.

coming soon

🏙️
Campus E.Coli and NTM Detection
.

💧
Stream Water Quality Monitoring
Time-series of field sensor data, detecting exceedances, and visualising spatial variation.

water quality

💧
Flood Return Interval
.

flooding

💧
Stream Discharge
.

tag

🦋
Biodiversity Surveys
Species richness, rarefaction curves, NMDS ordination, and PERMANOVA for plant and bird communities in the Pomona College Wash. Uses vegan.

ecology

📷
Camera Traps
Camera traps record who was present, when, and what they were doing without a researcher present. This tutorial walks the complete analytical pipeline — from raw Excel export through cleaning, independent-event definition, descriptive ethograms, and four quantitative methods: chi-square/Fisher tests of diel behavior shifts, kernel-density activity overlap, rarefaction-corrected diversity, and single-season occupancy modeling.

wildlife

💬
Sentiment Analysis of Environmental News
Measuring tone in environmental news with dictionary-based, aspect-based, and transformer methods. Build validated time-series sentiment indices from a text corpus using quanteda, sentimentr, tidytext, and the text package.

NLP / text

🛢️
Oil Price Forecasting
A 16-script ensemble forecasting pipeline for Brent crude and California gasoline. ARIMA-X, Prophet, LASSO, bias-penalized weighting, spot anchoring, GAM spread model, and diagnostic-driven iteration across multiple versions.

forecasting

🌡️
Temperature in Public Spaces
Comparing sun and shade temperatures in parks and public spaces across Southern California using paired iButton sensors. Analyze shade treatment effects with a linear mixed-effects model.

climate

🌦️
Regional Climate Trends
Analyzing long-term temperature and precipitation patterns across Southern California using PRISM and NOAA station data. Trend detection with Mann-Kendall tests and visualization of seasonal shifts.

coming soon

🏙️
Urban Heat Island
Raster data from Landsat, land-cover classification, and surface temperature analysis.

remote sensing

📍
GPS & Field Data Integration
Joining GPS tracks with field observations, plotting on basemaps, and exporting for reports.

coming soon

Additional Resources

External references and community tools curated for EA030.

📖
R for Data Science (2e)
Hadley Wickham & Mine Cetinkaya-Rundel. The canonical tidyverse reference, freely online.

external

🔍
Quick-R Reference
Dense, searchable reference for base-R syntax — useful as a cheat-sheet during lab sessions.

external

🎨
ggplot2 Reference
Full function reference for every geom, stat, scale, and theme component in ggplot2.

external

📋
Posit Cheatsheets
Official one-page PDF cheatsheets for ggplot2, dplyr, tidyr, RMarkdown, and more.

external

Quick Reference

Repository at github.com/marclos/RTricks. Each module contains an index.Rmd, a data/ folder, and rendered HTML. Clone or browse via the links.