Skip to content

Commit

Permalink
Update to using srvyrexploR (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
szimmer authored Feb 25, 2024
1 parent c500658 commit ed71045
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions 04-set-up.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ install.packages(c("tidyverse","survey"))
remotes::install_github("https://github.com/gergness/srvyr")
```

Additionally, to ensure that all readers can follow the examples throughout the book, we provide the analytic datasets in an R package, {srvyr.data}. Readers can install the package directly from GitHub using the {remotes} package.
Additionally, to ensure that all readers can follow the examples throughout the book, we provide the analytic datasets in an R package, {srvyrexploR}. Readers can install the package directly from GitHub using the {remotes} package.

```{r}
#| label: setup-install-core2
#| eval: FALSE
remotes::install_github("https://github.com/tidy-survey-r/srvyr.data")
remotes::install_github("https://github.com/tidy-survey-r/srvyrexploR")
```

Once these packages are installed, load these packages using the `library()` function:
Expand All @@ -33,7 +33,7 @@ Once these packages are installed, load these packages using the `library()` fun
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
```

In addition to these four packages, we want to highlight three others: {broom}, {gt}, and {gtsummary}. These help display output and create formatted tables that are easy to read and interpret. You will also want to make sure you install these packages using the following code^[Note that {broom} is part of the tidyverse, so it does not need to be installed separately]:
Expand Down Expand Up @@ -76,15 +76,15 @@ Additional packages are used in the vignettes. We list them in the Prerequisite

## Data

As mentioned above, the {srvyr.data} package includes the datasets used throughout the book. Once installed and loaded using the code above, readers can explore the documentation using the `help()` function and read the descriptions for the datasets provided:
As mentioned above, the {srvyrexploR} package includes the datasets used throughout the book. Once installed and loaded using the code above, readers can explore the documentation using the `help()` function and read the descriptions for the datasets provided:

```{r}
#| label: setup-datapkg-help
#| eval: FALSE
help(package="srvyr.data")
help(package="srvyrexploR")
```

The book provides examples and exercises using two key datasets: the American National Election Studies [ANES -- @debell] and the Residential Energy Consumption Survey [RECS -- @recs-2020-tech]. Use the `data()` command to load the datasets from the {srvyr.data} package into the environment. You can either load all datasets by using the `data()` function without any arguments, or you can include the specific datasets (e.g.,`recs_2020`) as an argument. In the code chunk below, we are loading the `anes_2020` and `recs_2020` datasets into objects with their respective names:
The book provides examples and exercises using two key datasets: the American National Election Studies [ANES -- @debell] and the Residential Energy Consumption Survey [RECS -- @recs-2020-tech]. Use the `data()` command to load the datasets from the {srvyrexploR} package into the environment. You can either load all datasets by using the `data()` function without any arguments, or you can include the specific datasets (e.g.,`recs_2020`) as an argument. In the code chunk below, we are loading the `anes_2020` and `recs_2020` datasets into objects with their respective names:

```{r}
#| label: setup-data-readin
Expand All @@ -100,7 +100,7 @@ data(recs_2020)

The ANES is a series study that has collected data from election surveys since 1948. These surveys contain data on public opinion and voting behavior in U.S. presidential elections. The 2020 survey (the data we use in the book) was fielded to individuals over the web, through live video interviewing, or with computer-assisted telephone interviewing (CATI). The survey includes questions on party affiliation, voting choice, and level of trust in the government.

When first looking at new survey data, data users should read the survey documentation (see Chapter \@ref(c03-understanding-survey-data-documentation) to understand how the data was collected and implemented). The original data from ANES contained variables starting with V20 [@debell], so to assist with our analysis throughout the book, we created descriptive variable names. For example, the respondent's age is now in a variable called `Age`, and gender is in a variable called `Gender`. These descriptive variables are included in the data from the {srvyr.data} package, and Table \@ref(tab:ANESvars) displays the list of these renamed variables. A complete overview of all variables can be found in `r if (!knitr:::is_html_output()) 'the online Appendix ('`Appendix \@ref(anes-cb)`r if (!knitr:::is_html_output()) ')'`.
When first looking at new survey data, data users should read the survey documentation (see Chapter \@ref(c03-understanding-survey-data-documentation) to understand how the data was collected and implemented). The original data from ANES contained variables starting with V20 [@debell], so to assist with our analysis throughout the book, we created descriptive variable names. For example, the respondent's age is now in a variable called `Age`, and gender is in a variable called `Gender`. These descriptive variables are included in the data from the {srvyrexploR} package, and Table \@ref(tab:ANESvars) displays the list of these renamed variables. A complete overview of all variables can be found in `r if (!knitr:::is_html_output()) 'the online Appendix ('`Appendix \@ref(anes-cb)`r if (!knitr:::is_html_output()) ')'`.

Table: (\#tab:ANESvars) List of Variables in the ANES Data
```{r}
Expand Down
2 changes: 1 addition & 1 deletion 05-descriptive-analysis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
library(broom)
```

Expand Down
2 changes: 1 addition & 1 deletion 06-statistical-testing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
library(broom)
library(gt)
```
Expand Down
2 changes: 1 addition & 1 deletion 07-modeling.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
library(broom)
```

Expand Down
2 changes: 1 addition & 1 deletion 08-communicating-results.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
library(gt)
library(gtsummary)
```
Expand Down
2 changes: 1 addition & 1 deletion 10-specifying-sample-designs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
```

To help explain the different types of sample designs, this chapter will use the `api` and `scd` data that comes in the {survey} package:
Expand Down
4 changes: 2 additions & 2 deletions 13-ncvs-vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ For this chapter, load the following packages:
library(tidyverse)
library(survey)
library(srvyr)
library(srvyr.data)
library(srvyrexploR)
library(gt)
```

We will use data from NCVS. Here is the code to read in the three datasets from the {srvyr.data} package:
We will use data from NCVS. Here is the code to read in the three datasets from the {srvyrexploR} package:
```{r}
#| label: ncvs-data
#| cache: TRUE
Expand Down
2 changes: 1 addition & 1 deletion 92-AppendixC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Stata:
library(haven)
anes_dta <-
read_dta(file = "data/anes_timeseries_2020_stata_20220210.dta")
read_dta(system.file("extdata", "anes_2020_stata_example.dta", package="srvyrexploR"))
```

SPSS:
Expand Down
14 changes: 7 additions & 7 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1847,20 +1847,20 @@
],
"Hash": "c77ebba142d814788bab0092bf102f6d"
},
"srvyr.data": {
"Package": "srvyr.data",
"Version": "0.1.0",
"srvyrexploR": {
"Package": "srvyrexploR",
"Version": "0.0.0.9000",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteRepo": "srvyrexploR",
"RemoteUsername": "tidy-survey-r",
"RemoteRepo": "srvyr.data",
"RemoteRef": "4deed50c78bbbd9847da001724a7f2315d06e8f5",
"RemoteSha": "4deed50c78bbbd9847da001724a7f2315d06e8f5",
"RemoteRef": "HEAD",
"RemoteSha": "076be1fa06ef112675b32c38462320a0e27fed30",
"Requirements": [
"R"
],
"Hash": "e5749bb48c61981ab533e63145cd305d"
"Hash": "3cd2bf2045557d71d5f17da5d30d6953"
},
"stringi": {
"Package": "stringi",
Expand Down

0 comments on commit ed71045

Please sign in to comment.