1What this book is¶
This is the R Help book for MATH 2200 at California State University, Bakersfield (CSUB). It teaches R itself — stepwise, from “what is R” all the way to fitting a regression model — so that the coursebook, the labs, and the homework can spend their time on statistics instead of re-explaining software.
R is not an elective add-on in this course. Course Learning Outcome CLO8 states it directly: “Demonstrate basic R proficiency to summarize and analyze data.” R appears on every lab, most homework sets, and both exams. This book is where that skill gets built, one lesson at a time, with real code and real output on every page — never a typed-up guess at what R would say.
2Why R is a graded skill here¶
Employers in every field this course serves — business analytics, nursing and health data, criminal-justice statistics, kinesiology research, applied psychology — now expect comfort with a statistical tool, and R is free, open-source, and used well beyond the classroom. Treating R as a skill you practice and get graded on (not a black box that produces numbers) is meant to make it something you can put on a resume, not something you forget the day after the final.
3The R stack this book teaches¶
MATH 2200 uses exactly two R packages for every statistical task:
mosaic (with its
ggformula plotting layer) and BSDA.
No other package appears in graded work. mosaic gives you one consistent
grammar — the formula goal( y ~ x, data = mydata ), read as “y broken
down by x” — for summaries, plots, and inference alike, so once you know
the pattern you can reuse it everywhere. BSDA adds the summary-statistics
tests (zsum.test, tsum.test) that textbook problems constantly ask for
when you’re given , , and instead of raw data.
Every lesson in this book, and everything in the coursebook and labs, sticks to this stack. If you see a different package name in a search result or a tutorial online, it is not wrong — it is just not what this course grades.
4How this book is organized¶
Fourteen lessons, in the order you will actually need them:
| Lesson | Topic | You’ll need it around |
|---|---|---|
| L01 | What is R & reproducible data analysis | Week 1 |
| L02 | Installing R & RStudio; the CSUB JupyterHub | Week 1 |
| L03 | Working in notebooks / RStudio; scripts & projects | Week 1 |
| L04 | R basics: objects, vectors, data frames, functions, help | Week 1–2 |
| L05 | Packages: mosaic + BSDA toolkit | Week 1–2 |
| L06 | Importing any data: built-in, CSV, Excel, URL, formula interface | Week 2 |
| L07 | Exploratory data analysis: favstats, tally, gf_ plots, faceting | Week 2–3 |
| L08 | Probability & distributions: xpnorm, dbinom, simulation with do() | Week 5 |
| L09 | Sampling distributions & the CLT by simulation | Week 6 |
| L10 | Confidence intervals & hypothesis tests | Week 6–9 |
| L11 | Two-sample & paired inference; chi-square | Week 8–11 |
| L12 | Correlation & linear regression | Week 12–13 |
| L13 | ANOVA and experimental-design basics | Week 11 |
| L14 | Troubleshooting common R errors | any time |
Lessons L01–L07 are complete now — they cover everything you need for the first month of the course: getting R running, the language basics, the mosaic/BSDA toolkit, reading in any kind of data, and exploring it. Lessons L08–L14 are stubbed with their objectives so you can see what’s coming; they fill in as the course reaches probability, inference, and regression.
5How this fits with the labs and the coursebook¶
The coursebook teaches the statistics: why a method exists, what its formula means, when to use it.
This R Help book teaches the software: exactly what to type, what it returns, and what to do when it doesn’t work.
The Jupyter labs (
labs/) put both together in a single guided, hands-on session each week.
If a lab or a homework problem says “see R Help Lxx,” that is a pointer back to the matching lesson here.
6A note on the data in this book¶
Most examples reuse one small, running dataset: a synthetic first-day
“campus survey” (coffee cups per day, sleep hours, commute minutes, cat- or
dog-person, class year, major, exam score). It is clearly simulated
classroom data (survey_sim.csv), generated by a committed, reproducible
script (data/make_survey_sim.R) — not a real CSUB survey. Using the same
dataset throughout means you spend your attention learning R, not
re-orienting to a new scenario every lesson. A few lessons also use R’s own
built-in datasets (like faithful, the Old Faithful eruption data, and
mosaicData::RailTrail) to show that everything you learn works on any
data frame, not just this one.
7Accessibility¶
This book is built to WCAG 2.1 AA: one heading per level, real headings (not bold text pretending to be a heading), real data tables, meaningful alt-text on every figure, and colorblind-safe (Okabe–Ito) plot colors that never rely on color alone. If something here does not work with your assistive technology, tell your instructor — the source is open and fixable.