1What this book is¶
R Help for Beginners teaches R itself — stepwise, from “what is R” all the way to fitting a regression model — so that a coursebook, a set of labs, or your own curiosity can spend its time on statistics instead of re-explaining software. It is built to stand on its own: every lesson defines its terms, shows real code, and shows the real output that code produced.
R is not an elective add-on in a modern statistics course. It is a skill worth having on its own, and 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.
2Who this book is for¶
This book is a common R companion for two CSUB courses — MATH 1209, Statistics in the Modern World, and MATH 2200, Introduction to Statistical Concepts and Methods — and it works equally well for anyone else learning R for an introductory statistics course, on any campus, or entirely on their own. It assumes no programming background at all. If you have never typed a line of code before, you are exactly who this book is for.
If a lab, a homework problem, or a coursebook chapter in your own course says “see R Help Lxx,” that is a pointer back to the matching lesson here. If you are working through this book on its own, with no course attached, every lesson still stands alone — just start at L01 and work forward.
3Two ways to run R¶
You need somewhere to actually type and run R code. There are two options, and you do not have to choose only one — most people end up using both at different points.
| CSUB JupyterHub (recommended) | Install locally (R + RStudio) | |
|---|---|---|
| Setup required | None — a web browser is enough | Install two programs, once |
| Works offline | No — needs internet | Yes |
| Works on a shared or library computer | Yes | Only if you can install software |
Packages this book uses (mosaic, BSDA) | Already installed for you | You install once |
| Good for | Getting started today, any device, no admin rights needed | Working offline, keeping R long-term |
If you only do one thing before your first R session, confirm you can
sign in to the CSUB JupyterHub at https://
4Why R is worth learning¶
Employers in every field an introductory statistics course tends to serve — business analytics, nursing and health data, criminal-justice statistics, kinesiology research, applied psychology, and more — 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 can explain (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.
If you are taking MATH 2200 at CSUB specifically, this is not just career advice — R proficiency is a named Course Learning Outcome (CLO8: “Demonstrate basic R proficiency to summarize and analyze data”), and R appears on labs, homework, and exams. Whether or not your own course numbers it that way, the same expectation shows up in spirit almost everywhere statistics is taught now.
5The R toolkit this book teaches¶
This book teaches exactly two R packages for every statistical task:
mosaic (with its
ggformula plotting layer) and BSDA.
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 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 book teaches, and if you are using this book alongside a specific course, it is likely not what that course grades either.
6How this book is organized¶
Fourteen lessons across eight parts, in the order you will actually need them:
6.1Part I · Getting Started¶
| Lesson | Topic |
|---|---|
| L01 | What is R & reproducible data analysis |
| L02 | Installing R & RStudio; the CSUB JupyterHub |
| L03 | Working in notebooks / RStudio; scripts & projects |
6.2Part II · R Foundations¶
| Lesson | Topic |
|---|---|
| L04 | R basics: objects, vectors, data frames, functions, help |
| L05 | Packages: the mosaic + BSDA toolkit |
| L06 | Importing any data: built-in, CSV, Excel, URL, formula interface |
6.3Part III · Exploring Data¶
| Lesson | Topic |
|---|---|
| L07 | Exploratory data analysis: favstats, tally, gf_ plots, faceting |
6.4Part IV · Probability & Distributions¶
| Lesson | Topic |
|---|---|
| L08 | Probability & distributions: xpnorm, dbinom, simulation with do() |
| L09 | Sampling distributions & the CLT by simulation |
6.5Part V · Statistical Inference¶
| Lesson | Topic |
|---|---|
| L10 | Confidence intervals & hypothesis tests |
| L11 | Two-sample & paired inference; chi-square |
6.6Part VI · Comparing Many Groups (ANOVA)¶
| Lesson | Topic |
|---|---|
| L13 | ANOVA and post-hoc comparisons (Tukey HSD) |
6.7Part VII · Regression¶
| Lesson | Topic |
|---|---|
| L12 | Correlation, simple & multiple linear regression |
6.8Part VIII · Reference¶
| Lesson | Topic |
|---|---|
| L14 | Troubleshooting common R errors |
All fourteen lessons are complete, with real, executed R and real output throughout. Work through them in order the first time — each one builds on R skills the last one taught — then come back to any lesson, or to L14, as a reference whenever you need it.
7How this fits with a course, if you’re taking one¶
If you are using this book alongside MATH 1209, MATH 2200, or another statistics course:
Your 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.
Jupyter labs, where your course provides them, put both together in a single guided, hands-on session.
If you are working through this book with no course attached at all, it still teaches the same R, end to end — just skip the “see your coursebook” asides and keep going.
8A 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 survey of any real students.
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.
9Accessibility¶
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 (or, if you’re on your own, raise it wherever this book was shared with you) — the source is open and fixable.