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

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 requiredNone — a web browser is enoughInstall two programs, once
Works offlineNo — needs internetYes
Works on a shared or library computerYesOnly if you can install software
Packages this book uses (mosaic, BSDA)Already installed for youYou install once
Good forGetting started today, any device, no admin rights neededWorking 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://csub.jupyter.cal-icor.org/ — it needs no installation, so it is the lowest-risk way to make sure you can do R work today, even if a local install runs into trouble later. L02 walks through both options in full, including a step-by-step JupyterHub tour for someone who has never opened it before.

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

LessonTopic
L01What is R & reproducible data analysis
L02Installing R & RStudio; the CSUB JupyterHub
L03Working in notebooks / RStudio; scripts & projects

6.2Part II · R Foundations

LessonTopic
L04R basics: objects, vectors, data frames, functions, help
L05Packages: the mosaic + BSDA toolkit
L06Importing any data: built-in, CSV, Excel, URL, formula interface

6.3Part III · Exploring Data

LessonTopic
L07Exploratory data analysis: favstats, tally, gf_ plots, faceting

6.4Part IV · Probability & Distributions

LessonTopic
L08Probability & distributions: xpnorm, dbinom, simulation with do()
L09Sampling distributions & the CLT by simulation

6.5Part V · Statistical Inference

LessonTopic
L10Confidence intervals & hypothesis tests
L11Two-sample & paired inference; chi-square

6.6Part VI · Comparing Many Groups (ANOVA)

LessonTopic
L13ANOVA and post-hoc comparisons (Tukey HSD)

6.7Part VII · Regression

LessonTopic
L12Correlation, simple & multiple linear regression

6.8Part VIII · Reference

LessonTopic
L14Troubleshooting 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:

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.