@@ -7,7 +7,7 @@ title-slide-attributes:
7
7
8
8
---
9
9
10
- # Welcome {background-color='{{< brand color secondary >}}'}
10
+ # Warm Up {background-color='{{< brand color secondary >}}'}
11
11
12
12
## Posit Cloud
13
13
<!-- TODO: Update this with Posit Cloud info-->
@@ -48,7 +48,7 @@ library(gt)
48
48
glimpse(towny)
49
49
```
50
50
51
- ## Your Turn {background-color='{{< brand color pink >}}' .smaller }
51
+ ## Your Turn {background-color='{{< brand color pink >}}'}
52
52
53
53
``` {r}
54
54
#| label: gs-ex-time
@@ -57,18 +57,9 @@ gs_ex_time <- 10
57
57
gs_ex_warn <- 3
58
58
```
59
59
60
+ - Open ` getting-started_exercises.qmd `
61
+ - Take ` r gs_ex_time ` minutes to set up Posit Cloud and finish the exercises individually. We will then go over together.
60
62
61
- - Take ` r gs_ex_time ` minutes to set up Posit Cloud and finish these exercises individually. We will then go over together.
62
-
63
- 1 . How many different types of CSD (` csd_type ` ) are there in the dataset?
64
- 2 . How many different types of CSD and status (` status ` ) are there in the dataset?
65
- 3 . What is the proportion of each type of CSD?
66
- 4 . What is the proportion of each status within type of CSD?
67
- 5 . What is the mean population of all of the municipalities in 2021?
68
- 6 . What is the mean population by CSD Type in 2021?
69
- 7 . What is the mean population of all of the municipalities in 1996, 2001, 2006, 2011, 2016, and 2021? Try to use the across function.
70
- 8 . Run a simple t-test to see if the average population in 1996 is different from the average population in 2016.
71
-
72
63
``` {r}
73
64
#| label: gs-ex-clock
74
65
#| echo: false
@@ -238,9 +229,39 @@ towny %>%
238
229
print(width=90)
239
230
```
240
231
241
- # Setup {background-color='{{< brand color secondary >}}'}
232
+ ## Ex. 8
233
+
234
+ Run a simple t-test to see if the average population in 1996 is different from the average population in 2016.
235
+
236
+ ``` {r}
237
+ #| label: ex-8-code
238
+ #| eval: false
239
+ t.test(towny$population_1996, towny$population_2016, paired = TRUE)
240
+ ```
241
+
242
+ . . .
243
+
244
+ ``` {r}
245
+ #| label: ex-8-outp-custprint
246
+ #| echo: false
247
+ t.test(towny$population_1996, towny$population_2016, paired = TRUE)
248
+ ```
249
+
250
+ # Packages {background-color='{{< brand color secondary >}}'}
251
+
252
+ ## R Packages for Survey Analysis
242
253
243
- ## Packages
254
+ - {survey} package first on CRAN in 2003
255
+ - descriptive analysis
256
+ - statistical testing
257
+ - modeling
258
+ - weighting
259
+
260
+ - {srvyr} package first on CRAN in 2016
261
+ - “wrapper” for {survey} with {tidyverse}-style syntax
262
+ - only descriptive analysis
263
+
264
+ ## Install Packages
244
265
245
266
Install packages for data wrangling and survey analysis:
246
267
@@ -275,15 +296,17 @@ library(srvyrexploR)
275
296
Note: Installation of packages is already done for you on Posit Cloud
276
297
:::
277
298
299
+ # Data {background-color='{{< brand color secondary >}}'}
300
+
278
301
## Today's Data
279
302
280
303
** American National Election Studies (ANES – DeBell 2010)**
281
304
282
- * Stored as ` anes_2020 `
305
+ * Stored as ` anes_2020 ` in {srvyrexploR}
283
306
284
307
** Residential Energy Consumption Survey (RECS – U.S. Energy Information Administration 2023b)**
285
308
286
- * Stored as ` recs_2020 `
309
+ * Stored as ` recs_2020 ` in {srvyrexploR}
287
310
288
311
## American National Election Studies (ANES) 2020 {.smaller}
289
312
@@ -363,7 +386,12 @@ anes_des <- anes_2020 %>%
363
386
ids = V200010c,
364
387
nest = TRUE
365
388
)
389
+ ```
366
390
391
+ ## American National Election Studies Design Object
392
+
393
+ ``` {r}
394
+ #| label: anes-des-show
367
395
anes_des
368
396
```
369
397
@@ -380,25 +408,14 @@ recs_des <- recs_2020 %>%
380
408
scale = 59 / 60,
381
409
mse = TRUE
382
410
)
383
-
384
- recs_des
385
411
```
386
412
387
- # Survey Analysis Process {background-color='{{< brand color secondary >}}'}
388
-
389
- ## Overview of Survey Analysis using {srvyr} Package
390
-
391
- ::: incremental
392
-
393
- 1 . Create a ` tbl_svy ` object (a survey object) using: ` as_survey_design() ` or ` as_survey_rep() `
394
-
395
- 2 . Subset data (if needed) using ` filter() ` (to create subpopulations)
396
-
397
- 3 . Specify domains of analysis using ` group_by() `
398
-
399
- 4 . Within ` summarize() ` , specify variables to calculate, including means, totals, proportions, quantiles, and more
413
+ ## Residential Energy Consumption Survey Design Object
400
414
401
- :::
415
+ ``` {r}
416
+ #| label: recs-des-show
417
+ recs_des
418
+ ```
402
419
403
420
# Similarities (and Differences) Between {dplyr} and {srvyr} Functions {background-color='{{< brand color secondary >}}'}
404
421
@@ -558,6 +575,22 @@ towny %>%
558
575
<<sv-non-svobj>>
559
576
```
560
577
578
+ # Survey Analysis Process {background-color='{{< brand color secondary >}}'}
579
+
580
+ ## Overview of Survey Analysis using {srvyr} Package
581
+
582
+ ::: incremental
583
+
584
+ 1 . Create a ` tbl_svy ` object (a survey object) using: ` as_survey_design() ` or ` as_survey_rep() `
585
+
586
+ 2 . Subset data (if needed) using ` filter() ` (to create subpopulations)
587
+
588
+ 3 . Specify domains of analysis using ` group_by() `
589
+
590
+ 4 . Within ` summarize() ` , specify variables to calculate, including means, totals, proportions, quantiles, and more
591
+
592
+ :::
593
+
561
594
# Wrap Up {background-color='{{< brand color secondary >}}'}
562
595
563
596
## Wrap Up
0 commit comments