-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathchapter1.Rmd
426 lines (316 loc) · 12.2 KB
/
chapter1.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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
---
title: 'Lab 1 - Intro to probability and data'
description: 'Questions for Lab 1'
---
## Question 1
```yaml
type: ExplorableExercise
key: 02d4222b54
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file:</strong>
```Type 'go()' and hit Enter to get started!```
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q1. How many variables are included in this data set?</strong>
`@possible_answers`
- 2
- 3
- 4
- 82
- 1710
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 1)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.init.R
# lab1_ex1.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex1.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "Great work!"
msg3 <- "Keep trying!"
msg4 <- "Nope."
msg5 <- "Not quite."
ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
```
---
## Question 2
```yaml
type: ExplorableExercise
key: 5440b387f2
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q2. What command would you use to extract just the counts of girls born?</strong>
`@possible_answers`
- `arbuthnot$boys`
- `arbuthnot$girls`
- `girls`
- `arbuthnot[girls]`
- `$girls`
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 2)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.init.R
# lab1_ex2.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex2.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Not quite."
msg2 <- "Nice job!"
msg3 <- "Keep trying!"
msg4 <- "Nope!"
msg5 <- "Try again!"
ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
```
---
## Question 3
```yaml
type: ExplorableExercise
key: eb6689ed9c
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q3. Which of the following best describes the number of girls baptised over the years included in this dataset?
`@possible_answers`
- There appears to be no trend in the number of girls baptised from 1629 to 1710.
- There is initially an increase in the number of girls baptised, which peaks around 1640. After 1640 there is a decrease in the number of girls baptised, but the number begins to increase again in 1660. Overall the trend is an increase in the number of girls baptised.
- There is initially an increase in the number of girls baptised. This number peaks around 1640 and then after 1640 the number of girls baptised decreases.
- The number of girls baptised has decreased over time.
- There is an initial increase in the number of girls baptised but this number appears to level around 1680 and not change after that time point.
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 3)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.init.R
# lab1_ex3.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex3.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "Awesome!"
msg3 <- "Keep trying!"
msg4 <- "Try again."
msg5 <- "Try again."
ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
```
---
## Question 4
```yaml
type: ExplorableExercise
key: e64497e7f4
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q4. How many variables are included in this data set?</strong>
`@possible_answers`
- 2
- 3
- 4
- 74
- 2013
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 4)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.init.R
# lab1_ex4.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex4.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "You got it!"
msg3 <- "Keep trying!"
msg4 <- "Try again."
msg5 <- "Try again."
ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
```
---
## Question 5
```yaml
type: ExplorableExercise
key: b073c8a4d3
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q5. Has the proportion of boys born in the US has decreased over time.
`@possible_answers`
- TRUE
- FALSE
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 5)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.init.R
# lab1_ex5.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex5.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "That's right!"
msg2 <- "Try again."
ex() %>% check_mc(1, feedback_msgs = c(msg1, msg2))
```
---
## Question 6
```yaml
type: ExplorableExercise
key: 8aee5ae535
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q6. Which of the following statements is true?</strong>
`@possible_answers`
- Every year there are more girls born than boys.
- Every year there are more boys born than girls.
- Half of the years there are more boys born, and the other half more girls born.
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 6)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.init.R
# lab1_ex6.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex6.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "Great work!"
msg3 <- "Keep trying!"
ex() %>% check_mc(2, feedback_msgs = c(msg1, msg2, msg3))
```
---
## Question 7
```yaml
type: ExplorableExercise
key: 63abfd6950
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q7. Which of the following best describes the trend?</strong>
`@possible_answers`
- There appears to be no trend in the boy-to-girl ratio from 1940 to 2013.
- There is initially an increase in boy-to-girl ratio, which peaks around 1960. After 1960 there is a decrease in the boy-to-girl ratio, but the number begins to increase in the mid 1970s.
- There is initially a decrease in the boy-to-girl ratio, and then an increase between 1960 and 1970, followed by a decrease.
- The boy-to-girl ratio has increased over time.
- There is an initial decrease in the boy-to-girl ratio born but this number appears to level around 1960 and remain constant since then.
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 7)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.init.R
# lab1_ex7.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex7.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "Keep trying!"
msg3 <- "Awesome, you did great!"
msg4 <- "Try again."
msg5 <- "Try again."
ex() %>% check_mc(3, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
```
---
## Question 8
```yaml
type: ExplorableExercise
key: ca476ff87f
xp: 50
skills: 1
```
<strong>Follow the directions in the console to open the R Markdown file.</strong>
You can use the RStudio platform just like you would on your home computer.
The markdown file contains the instuctions to answer the multiple choice question below.
<strong>Q8. In what year did we see the most total number of births in the U.S.?</strong>
`@possible_answers`
- 1940
- 1957
- 1961
- 1991
- 2007
`@hint`
Check out the instructions in the .Rmd file to answer the multiple choice question.
`@pre_exercise_code`
```{r}
# Import the helper file contained in the image
source('/usr/local/lib/R/site-library/run_rstudio.R')
# Run a new RStudio session and serve it to the user
run_rstudio(1, 8)
# .Rprofile: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.Rprofile
# .init.R: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.init.R
# lab1_ex8.Rmd: https://assets.datacamp.com/production/course_1156/datasets/lab1_ex8.Rmd
# lab.css: https://assets.datacamp.com/production/course_1156/datasets/lab.css
# lab8_wk.RData: https://assets.datacamp.com/production/course_1156/datasets/lab8_wk.RData
```
`@sct`
```{r,eval=FALSE}
msg1 <- "Try again."
msg2 <- "Try again."
msg3 <- "Keep trying!"
msg4 <- "Try again."
msg5 <- "Awesome!"
ex() %>% check_mc(5, feedback_msgs = c(msg1, msg2, msg3, msg4, msg5))
success_msg("Click [here](https://assets.datacamp.com/production/repositories/302/datasets/720e84184f8aee15916dd20a19398373827d4b04/ch1_key.Rmd) to get a complete Rmarkdown file of the exercises in this Lab and click [here](https://assets.datacamp.com/production/repositories/302/datasets/9ecc2629166b0b8a841f15a83710ddff282baecc/ch1_key.html) to get the Knitted HTML output.")
```