Preface
I Getting started
1
Introduction
1.1
Why statistics?
1.2
The parable of belief bias
1.3
Statistics in psychology
1.4
Statistics in everyday life
1.5
On the limitations of statistics
2
Getting started in R
2.1
Why learn R?
2.2
First steps
2.2.1
Installing R & RStudio
2.2.2
R commands
2.2.3
Avoid typos
2.2.4
R is flexible with spacing?
2.2.5
R knows you’re not finished?
2.3
Operations
2.3.1
Arithmetic operations
2.3.2
Order of operations
2.4
Functions
2.4.1
Using functions
2.4.2
Combining functions
2.4.3
Multiple arguments
2.4.4
Argument names
2.4.5
Default values
2.5
RStudio helps!
2.5.1
Tab autocomplete
2.5.2
The history pane
2.6
Exercises
2.7
Project oriented workflow
II Exploring data
3
Pretty pictures
3.1
R graphics
3.2
The data set
3.3
Histograms
3.4
Scatter plot
3.5
Bar graphs
3.6
Box plots
3.7
Violin plots
3.8
Facetted plots
3.9
Bubble plots
3.10
Error bars
3.11
Other possibilities
3.12
Saving images
3.13
Further reading
4
Describing data
III Learning from data
5
Probability
6
Orthodox theory
7
Bayesian theory
8
Linear models
IV Tools of the trade
9
Cleaning data
10
Documenting your work
Appendices
A
Data types in R
A.1
Vectors
A.1.1
Character vectors
A.1.2
Numeric vectors
A.1.3
Extracting an element
A.1.4
Extracting multiple elements
A.1.5
Removing elements
A.1.6
Editing vectors
A.1.7
Naming elements
A.1.8
Vector operations
A.1.9
Logical vectors
A.1.10
Comment
A.1.11
Exercises
A.2
Factors
A.2.1
Unordered factors
A.2.2
Ordered factors
A.3
Data frames / tibbles
A.3.1
Making a data frame
A.3.2
Making a tibble
A.3.3
Tibbles are data frames
A.3.4
Using the
$
operator
A.3.5
Using square brackets
A.4
Matrices
A.4.1
Matrix indexing
A.4.2
Matrices vs data frames
A.4.3
Other ways to make a matrix
A.5
Arrays
A.5.1
Array indexing
A.5.2
Array names
A.6
Lists
A.6.1
Indexing lists
A.7
Dates
A.8
Coercion
B
Programming in R
B.1
If/else
B.1.1
Example 1:
B.1.2
Example 2:
B.1.3
Exercises
B.2
Loops
B.2.1
The
while
loop
B.2.2
A simple example
B.2.3
Mortgage calculator
B.2.4
The
for
loop
B.2.5
Multiplication tables
B.2.6
Looping over other vectors
B.2.7
Vectorised code?
B.2.8
Exercises
B.3
Functions
B.3.1
A boring example
B.3.2
Default arguments
B.3.3
Unspecified arguments
B.3.4
More on functions?
B.4
Rescorla-Wagner model
B.4.1
The model itself
B.4.2
R implementation
B.4.3
The skeleton
B.4.4
Make a plan
B.4.5
Fill in the pieces
B.4.6
Tidying
B.4.7
Model predictions
B.4.8
Conditioning
B.4.9
Extinction
B.4.10
Blocking
B.4.11
Done!
References
Learning statistics with R
References