Preface
Quickstart
Acknowledgements
1
Introduction to R
1.1
What is R?
1.2
Packages
1.2.1
Base R
1.2.2
Contributed packages
1.2.3
Installing Packages
1.2.4
Using and Loading Packages
1.2.5
Packages Required for This Tutorial
1.3
Using R
1.3.1
R as a Calculator
1.3.2
Assigning Variables
1.3.3
Rounding
1.3.4
Vectors
1.3.5
Plotting
1.3.6
Exercises
1.4
Documentation and Help
1.4.1
Built-in Documentation and Help
1.4.2
Web search
1.4.3
Online Guides for R
1.4.4
Online Cheatsheets
1.5
The Importance of Being Precise
2
Working with Data
2.1
Loading Data
2.1.1
The
Import Dataset
RStudio Button
2.1.2
The
read_csv()
Function (in the
readr
package)
2.1.3
The Working Directory
2.2
Exploring Data
2.2.1
Summary Functions
2.3
Plotting Data
2.3.1
Bar Plots
2.3.2
Histograms
2.3.3
Box Plots
3
Bivariate Data
3.1
Bivariate Plots
3.1.1
Box Plots
3.1.2
Scatter Plots
3.2
Bivariate Numerical Summaries
3.2.1
Covariance
3.2.2
Correlation
3.3
Simple Linear Regression
3.3.1
Plotting the Regression Line
3.3.2
Reverse Regression
4
Bivariate Data
4.1
Bivariate Plots
4.1.1
Box Plots
4.1.2
Scatter Plots
4.2
Bivariate Numerical Summaries
4.2.1
Covariance
4.2.2
Correlation
4.3
Simple Linear Regression
4.3.1
Plotting the Regression Line
4.3.2
Reverse Regression
5
Tabular Data
5.1
Two-Way Tables
5.1.1
Matrices
5.1.2
Example Dataset
5.1.3
Working with Two-Way Tables
5.1.4
Distributions in Two-Way Tables
5.1.5
Exercises
5.2
Simpson’s Paradox
5.3
Sensitivity and Specificity
6
Study Design
6.1
Locate Article
6.2
Literature Exercise
6.2.1
Article Citation
6.2.2
Critical Reading
7
Exploring Distributions of Random Variables Through Simulation
7.1
Simulating Random variables for Individual Events
7.1.1
Flipping Coins
7.1.2
Rolling Dice
7.1.3
Plotting Results
7.2
Discrete Distributions
7.2.1
The Bernoulli Distribution
7.2.2
The Binomial Distribution
7.2.3
The Poisson Distribution
7.3
Continuous Distributions
7.3.1
The Normal Distribution
7.3.2
The Exponential Distribution
7.4
Limit Theorems
7.4.1
The Law of Large Numbers
7.4.2
The Central Limit Theorem
7.5
Additional examples
7.5.1
The Uniform Distribution
8
Inference
Example Dataset: Theo’s Chocolate Bars
8.1
Confidence Intervals
8.1.1
Illustrating Confidence Intervals
8.2
Hypothesis Tests
8.2.1
Illustrating a Hypothesis Test
8.2.2
Hypothesis Tests for Means
8.2.3
Two-sample Tests
8.2.4
Tests for Proportions
8.2.5
Power
9
Regression
Example Dataset: U.S. Democratic Votes by State
9.1
Linear Regression
9.2
Checking Model Assumptions
9.3
Testing Individual Coefficients
9.4
Confidence Intervals for the Parameter Estimates
9.5
Confidence and Prediction Intervals for specific values of
\(X\)
9.6
Omnibus tests for “Goodness of Fit”
10
Chi-squared Test
11
Accessing Literature
11.1
Academic Search Engines
11.1.1
Google Scholar
11.1.2
Other Search Engines
11.2
Accessing Literature Through Paywalls
12
Appendix
12.1
Random Seeds
Introduction to Statistics with R
3
Bivariate Data