/
index.Rmd
240 lines (184 loc) · 9.43 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
---
title: '<div class="jumbotron"><h1 class="title toc-ignore display-3" align="center">R for Psychological Science</h1><p class="lead" align="center">by Danielle Navarro <a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a></p></div>'
output:
html_document:
includes:
in_header: header.html
theme: flatly
highlight: textmate
css: mystyle.css
---
```{r,echo=FALSE}
rm(list=objects()) # start with a clean workspace
source("knitr_tweaks.R")
```
## {.tabset}
### Welcome!
Hi there!
I've set this up as an introductory resource for psychology students taking my *Programming with R* class at UNSW. There are two goals with this resource. The first is to provide an introduction to R programming that doesn't assume any previous experience. The second is to provide a brief sketch of some of things that R can be useful for in psychology. Data analysis inevitably forms a large part of this, but I hope to cover a broader range of topics.
The content borrows from my introductory statistics lecture notes ([Learning Statistics with R](https://learningstatisticswithr.com/)), but they're not equivalent, and over time the two are likely to part ways. I wrote *Learning Statistics with R* to accompany an introductory statistics class and the intended audience for that book is a psychology student taking their first research methods class. This resource is a little different -- it's aimed at someone who has taken at least one research methods class and would like to learn how to use the R programming language in their own work.
It is of course a work in progress, but I hope it is useful! Please don't hesitate to contact me if you spot an error or find something confusing.
-- Danielle
<img src="./img/splash_turtle2.png" width=250px>
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>
### 1: Core toolkit
- [Getting started](./getting-started.html)
- [Variables](./variables.html)
- [Scripts](./scripts.html)
- [Packages](./packages.html)
- [Workspaces](./workspaces.html)
- [Vectors](./vectors.html)
- [Loops](./loops.html)
- [Branches](./branches.html)
- [Functions](./functions.html)
- [Programming](./programming.html)
- [File system](./file-system.html)
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>
### 2: Working with data
Everything from here onwards is *very much* a work in progress!
- [Prelude to data](./prelude-to-data.html)
- [Data types](./data-types.html)
- [Describing data](./describing-data.html)
- [Visualising data](./visualising-data.html)
- [Manipulating data](./manipulating-data.html) <span style="color:#cccccc">(draft)</span>
- [Working with text](./working-with-text.html) <span style="color:#cccccc">(draft)</span>
- [Import and export](./import-export.html) <span style="color:#cccccc">(stub)</span>
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>
### 3: Statistics
- [Probability distributions](./probability.html) <span style="color:#cccccc">(draft)</span>
- [Introductory statistics](./introductory-statistics.html) <span style="color:#cccccc">(draft)</span><!-- add Bayes factor -->
- [Intermediate statistics](./intermediate-statistics.html) <span style="color:#cccccc">(stub)</span>
- [Advanced statistics](./advanced-statistics.html) <span style="color:#cccccc">(stub)</span>
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>
### 4: More topics
- [Behavioural experiments](./experiments.html) <span style="color:#cccccc">(draft)</span>
- [Shiny web applications](./shiny.html) <span style="color:#cccccc">(draft)</span>
- [Web scraping](./web-scraping.html) <span style="color:#cccccc">(draft)</span>
- [Miscellaneous](./xx-miscellaneous.html) <span style="color:#cccccc">(draft)</span>
- <span style="color:#cccccc">Image processing in R (to be added)</span> <!-- imager -->
- <span style="color:#cccccc">Authoring documents in R (to be added)</span> <!-- markdown, blogdown, papaja -->
- [Backpropagation networks](./backprop.html) <span style="color:#cccccc">(draft)</span>
- <span style="color:#cccccc">More computational modelling (to be added)</span> <!-- Rescorla-Wagner, GCM -->
- <span style="color:#cccccc">Writing an R package (to be added)</span> <!-- very simple guide -->
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>
### Links
- Week 1 slides: [pptx](./misc/overview.pptx), [pdf](./misc/overview.pdf)
- Week 2 workbook: [here](./lesson2.html)
- Week 3 slides: [here](https://slides.com/djnavarro/psyc-3361-workshop-3/)
- Data sets are [here](./misc/data.zip)
- Github repository is [here](https://github.com/djnavarro/psyr)
- A nice [resource](http://environmentalcomputing.net/) put together by the UNSW folks in BEES.
Some extra links re data:
- the AFL data is [here](./data/afl.csv)
- the orientation data is [here](./data/orientation.csv)
- the reasoning data is [here](./data/frames_ex2.csv), and in wide form [here](./data/frames_ex2_wide.csv)
- the titanic data is [here](./data/titanic3.csv) courtesy [here](biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic3.xls)
Alternatively use R data sets:
- `data(diamonds)`: prices of 50,000 round cut diamonds (type `?diamonds`)
- `data(iris)`: information about different kinds of flowers (`?iris`)
- `data(mtcars)`: fuel efficiency of old cars (`?mtcars`)
- `data(midwest)`: population information in the US...
- `data(starwars)`: characters from star wars...
- etc
Some documentation for the original data sets here.
<br>
The [AFL data](./data/afl.csv) consists of single CSV file that contains information about every game played in the Australian Football League from 1987 to 2010. In total there are X cases (games) and Y variables recorded. The variables recorded are:
- `home_team`: the name of the home team
- `away_team`: the name of the away team
- `home_score`: number of points scored by the home team
- `away_score`: number of points scored by the away team
- `year`: year in which the game was played
- `round`: season week number in which the game was played
- `weekday`: day of the week in which the game was played
- `day`: day of the month in which the game was played
- `month`: month of the year in which the game was played
- `game_type`: was this a `regular` game or part of the `finals` series?
- `venue`: the name of the stadium hosting the game
- `attendance`: official attendance at the game
The [users data](./data/users.csv) os a single CSV file containing 148 days of web traffic data for my now-defunct lab website, collected via Google Analytics. I will likely extend this at a later date, but at the moment it includes only two fields:
- `Date`: the date for which the statisics are reported
- `Users`: the number of unique users accessing the site
The [frames data](./data/frames_ex2.csv) contains data from Experiment 2 of Hayes et al (under review). It contains the following variables:
- `id`
- `gender`
- `age`
- `condition`
- `sample_size`
- `n_obs`
- `test_item`
- `response`
<!--
## Topics I want to add
- Cognitive modelling
- Basic text processing & regular expressions
- Fancier statistics
- Bayesian data analysis (rstanarm, shinystan, bayesfactor)
- RMarkdown, knitr & pandoc (& jupyter notebooks)
- Prettiness with [htmlwidgets](http://www.htmlwidgets.org/index.html)
- Archiving code with github, osf (& codeocean)
- Source code for this site: https://github.com/djnavarro/psyr
- Exercises: programming with turtles ([part1](./misc/turtle1.html), [part2](./misc/turtle2.html))
- Week 1 slides are posted [here](./misc/overview.pdf)
- Week 2 notebook is posted [here](./misc/lesson2.nb.html) with output version [here](./misc/lesson2.html)
-->
<br>
<center>
----
<a href="https://twitter.com/djnavarro"><i class="fab fa-twitter"></i></a>
<a href="https://djnavarro.net"><i class="fas fa-home"></i></a>
<a href="https://github.com/djnavarro"><i class="fab fa-github"></i></a>
<a href="mailto:d.navarro@unsw.edu.au"><i class="fas fa-paper-plane"></i></a>
----
</center>
<br>
<br>