A companion to Statistics in the Modern World at CSU Bakersfield.
1Who this book is for¶
You have never written a line of code. That is completely normal, and this book assumes exactly that. Maybe you are a business major, a nursing major, a kinesiology major, or you just needed a GE math course that fit your schedule — the statistics is the point of MATH 1209, not the software. This little book exists because your instructor wants to show you the same statistics you’re learning by hand and by calculator, running in a free, real tool that people use in jobs after college.
2How to use this book¶
The 12 lessons build on each other, so read them roughly in order the first time — after that, treat it like a reference and jump straight to the lesson you need.
| # | Lesson | What you’ll be able to do |
|---|---|---|
| 1 | What is R, and why use it? | Explain what R is and why this course uses it |
| 2 | Installing R & RStudio, and CSUB JupyterHub | Get R running on your own computer, or skip installing anything |
| 3 | Running R: notebooks, the console, scripts | Pick the right way to run a line of R for the situation you’re in |
| 4 | R basics: objects, vectors, functions, help | Store values, build a list of numbers, call a function, read an error |
| 5 | Packages: install & library; our toolkit | Turn on the mosaic and BSDA tools this course uses |
| 6 | Importing data | Load a built-in dataset, a CSV file, or data from the internet |
| 7 | Exploring data (EDA) in R | Summarize and visualize data with favstats(), tally(), and gf_ plots |
| 8 | Probability & the Normal model | Find Normal and binomial probabilities and simulate chance in R |
| 9 | Confidence intervals & tests | Run and read the output of prop.test(), t.test(), and the summary tests |
| 10 | Making good graphs | Build clear, colorblind-safe, accessible graphs and write good alt text |
| 11 | Reproducibility & good habits | Write scripts that run start-to-finish and reproduce with set.seed() |
| 12 | Fixing common errors | Recognize and fix the most common R error messages |
Each lesson follows the same shape: a plain-language idea, small examples you can copy and run yourself, and real R output — every result printed in this book was actually run in R, not typed in by hand, so what you see here is what you’ll see on your own screen.
3What you need¶
Nothing, to start. You can do every example in this book using the CSUB JupyterHub in a browser — no installation (see Lesson 2).
If you’d rather work on your own laptop, Lesson 2 also walks through installing R and RStudio on Windows or Mac, free.
This book uses only two R packages all semester:
mosaicandBSDA(Lesson 5). You never need anything beyond those two for MATH 1209.
4The voice of this book¶
Short sentences. Every new word explained the moment it shows up. Lots of tiny examples instead of one long one. If a line of code in this book produces output, that output is shown right underneath it, exactly as R printed it.
This is a free, openly licensed book (CC BY-SA 4.0 for the text; MIT for the code examples). You never have to buy anything to use it.