Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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 xˉ\bar{x}, ss, and nn 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:

LessonTopicYou’ll need it around
L01What is R & reproducible data analysisWeek 1
L02Installing R & RStudio; the CSUB JupyterHubWeek 1
L03Working in notebooks / RStudio; scripts & projectsWeek 1
L04R basics: objects, vectors, data frames, functions, helpWeek 1–2
L05Packages: mosaic + BSDA toolkitWeek 1–2
L06Importing any data: built-in, CSV, Excel, URL, formula interfaceWeek 2
L07Exploratory data analysis: favstats, tally, gf_ plots, facetingWeek 2–3
L08Probability & distributions: xpnorm, dbinom, simulation with do()Week 5
L09Sampling distributions & the CLT by simulationWeek 6
L10Confidence intervals & hypothesis testsWeek 6–9
L11Two-sample & paired inference; chi-squareWeek 8–11
L12Correlation & linear regressionWeek 12–13
L13ANOVA and experimental-design basicsWeek 11
L14Troubleshooting common R errorsany 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

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.