R Tips
Short videos + runnable code for R and the tidyverse
A series of short videos (each under 5 minutes) for R and the tidyverse. Each tip pairs a video with a companion page that runs the same code, so you can watch, then do.
The tips are ordered to flow: environment \(\to\) data \(\to\) tidyverse \(\to\) ggplot \(\to\) infer \(\to\) tidymodels \(\to\) Quarto reports. Where a tip draws on a MATH 1051 lab, the page links to it.
Note
Tips are being filmed. Pages marked coming soon will get their video and runnable code as the series progresses.
1. Getting started
- Install & load packages — install.packages() vs library(), CRAN, the
pkg::fn()form - Variables & assignment —
<-, what a variable holds, naming - The pipe
|>— chaining operations - Quarto + RStudio setup — chunks, inline R, knitting
- Reading data — read_csv() / read_excel(), tibble vs data.frame
- Looking at a tibble — names(), str(), head(), dim()
2. dplyr: the verbs
- filter() — keep rows
- select() — pick and rename columns
- mutate() — create or modify columns
- arrange() & friends — sort, slice(), n(), distinct()
- group_by() + summarise() — split-apply-combine
- Pipes in practice — a full pipeline, step by step
3. tidyr & joins
- Tidy data — wide vs long
- pivot_longer() / pivot_wider() — reshaping
- Joins — inner_join() vs left_join()
4. ggplot2
- Anatomy of a plot — ggplot() + aes() + one layer
- Facets — small multiples
- Labels & themes — labs(), theme, scales
- Distributions — histograms, boxplots, smooths
5. infer: inference
- The sampling distribution — why a sample mean varies
- t_stat() — the test statistic by hand
- t_test() — hypothesize, resample, observe
- Confidence intervals — conf_int() and how to read one
- Bootstrapping — bootstrap CIs
- p-values & Type I error — what alpha actually means
6. tidymodels
- What tidymodels is — the framework, and what a spec is for
- lm() with tidy() / glance() / augment() — modeling in tidyverse shape
- Residuals & diagnostics — augment() + residual plots
- Workflows — a repeatable model pipeline
- Evaluating models — train/test split + metrics
- Tuning intro — grids and tune(), kept simple
- Classification intro — logistic_reg(), roc_curve()
7. Quarto reports (capstone)
- Tables with kable / kableExtra
- Figures, citations & footnotes
- Side-by-side tables in PDFs —
layout-ncol,tbl-capandtbl-subcap