-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-intro.Rmd
256 lines (168 loc) · 5.09 KB
/
1-intro.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
---
title: "1. Intro to R"
subtitle: "Analytics Sandbox"
author: "K. Bret Staudt Willet | Florida State University"
date: "January 11, 2023"
output:
xaringan::moon_reader:
lib_dir: libs
seal: true
css: [default, 'css/custom.css', 'css/custom-fonts.css']
nature:
titleSlideClass: [left, bottom]
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(knitr)
library(tidyverse)
library(xaringan)
library(fontawesome)
```
class: inverse, center, middle
# `r fa("fas fa-otter", fill = "#fff")` <br><br> **Part 1:** <br> Introduction to R
---
# `r fa("fas fa-otter", fill = "#fff")` Our Constructivist Approach
--
1. We'll introduce some concepts
1. You'll try some code
1. We'll all discuss together
--
```{r, out.width = "360px", echo = FALSE, fig.align = "center"}
include_graphics("img/tech_support_cheat_sheet.png")
```
<div class="caption">
<p><a href="https://xkcd.com/627/" target="_blank">'Tech Support Cheat Sheet' from XKCD</a></p>
</div>
---
class: inverse, center, middle
# `r fa("fab fa-r-project", fill = "#fff")` <br><br> Background <br> on R and RStudio
---
# `r fa("fab fa-r-project", fill = "#fff")` Why Learn R?
--
- It is increasingly used in education
--
- It is cross-platform, open-source, and freely-available
--
- It is a programming language and quite flexible
--
- It is capable of carrying out basic and complex statistical analyses
--
- It is able to work with data small (*n* = 10) and large (*n* = 1,000,000+) efficiently
--
- There is a great, inclusive community of users and developers
---
# `r fa("fab fa-r-project", fill = "#fff")` Setting up R
### To download R
- Visit [**cran.r-project.org**](https://cran.r-project.org/) to download R
- Find your operating system (Mac, Windows, or Linux)
- Download the 'latest release' on the page for your operating system and download and install the application
### To download RStudio
- Visit [**rstudio.com**](https://rstudio.com/products/rstudio/download/) to download RStudio
- Find your operating system (Mac, Windows, or Linux)
- Download the 'latest release' on the page for your operating system and download and install the application
---
class: inverse, center, middle
# `r fa("fas fa-otter", fill = "#fff")` <br><br> Try it Out!
---
# `r fa("fab fa-r-project", fill = "#fff")` Getting Started with RStudio
Activities:
1. Running a single RMarkdown chunk
1. Running another RMarkdown chunk
1. Rendering an RMarkdown document to a PDF
1. Creating your first visualization
---
# `r fa("fab fa-r-project", fill = "#fff")` RMarkdown
- RMarkdown is a data analysis "notebook" that combines text with code and output
- It is a great file type to use when beginning to use R and to create reproducible analyses
- It is fun to use because you can generate different types of output (Word, PDF, and even web-based)
---
class: inverse, center, middle
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
What do you think this code will do?
```{r, eval = FALSE}
starwars %>%
filter(sex == "female") %>%
select(name, hair_color, skin_color, homeworld)
```
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
Let's see!
```{r, eval = TRUE}
starwars %>%
filter(sex == "female") %>%
select(name, hair_color, skin_color, homeworld)
```
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
What do you think this code will do?
```{r, eval = FALSE}
starwars %>%
filter(sex %in% c("male", "none"),
height <= 150) %>%
select(name, sex, height, mass, homeworld) %>%
arrange(desc(height))
```
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
Let's see!
```{r, eval = TRUE}
starwars %>%
filter(sex %in% c("male", "none"),
height <= 150) %>%
arrange(height) %>%
select(name, sex, height, mass, homeworld)
```
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
```{r, echo = TRUE}
starwars %>%
unnest(starships) %>%
select(name, gender, starships) %>%
head(10)
```
---
# `r fa("fas fa-otter", fill = "#fff")` Try it Out!
```{r, echo = TRUE}
starwars %>%
unnest(starships) %>%
mutate(vehicles = strsplit(starships, ",")) %>%
unnest(starships) %>%
select(name, gender, starships) %>%
group_by(gender) %>%
count()
```
---
# `r fa("fas fa-otter", fill = "#fff")` Exploring further
```{r, echo = TRUE}
glimpse(starwars)
```
---
# `r fa("fas fa-otter", fill = "#fff")` Visualizing data
```{r, echo = TRUE, warning = FALSE}
starwars %>%
ggplot() +
geom_point(aes(x = mass, y = height, color = gender),
alpha = 0.5
) +
theme_bw()
```
---
class: inverse, center, middle
# `r fa("fas fa-code", fill = "#fff")` <br><br> Try it out!
Hop over to [**Workbook 1**](workbooks/workbook1.Rmd)
---
class: inverse, center, middle
# `r fa("fas fa-list", fill = "#fff")` <br><br> Appendix: <br> Helpful Resources <br> and Troubleshooting
---
# Resources
```{r child="notes/resources.Rmd"}
```
---
# Troubleshooting
```{r child="notes/troubleshooting.Rmd"}
```