diff --git a/04-set-up.Rmd b/04-set-up.Rmd index d533baf..62441d0 100644 --- a/04-set-up.Rmd +++ b/04-set-up.Rmd @@ -98,7 +98,7 @@ Note that the {censusapi} package requires a Census API key, available for free ```{r} #| label: setup-census-api-setup #| eval: FALSE -Sys.setenv(CENSUS_KEY="YOUR_API_KEY_HERE") +Sys.setenv(CENSUS_KEY = "YOUR_API_KEY_HERE") ``` Then, restart the R session. Once the Census API key is stored, we can retrieve it in our R code with `Sys.getenv("CENSUS_KEY")`. @@ -287,7 +287,7 @@ There is a general process for analyzing data to create estimates with {srvyr} p 4. Within `summarize()`, specify variables to calculate, including means, totals, proportions, quantiles, and more -In Section \@ref(setup-des-obj), we follow Step 1 to create the survey design objects for the ANES and RECS data featured in this book. Additional details on how to create design objects can be found in Chapter \@ref(c10-sample-designs-replicate-weights). Then, once we have the design object, we can filter the data to any subpopulation of interest (if needed). It is important to filter the data **after** creating the design object. This ensures that we are accurately accounting for the survey design in our calculations. Finally, we can use `group_by()`, `summarize()`, and other functions from the {survey} and {srvyr} packages to analyze the survey data by estimating means, totals, and so on. +In Section \@ref(setup-des-obj), we follow Step 1 to create the survey design objects for the ANES and RECS data featured in this book. Additional details on how to create design objects can be found in Chapter \@ref(c10-sample-designs-replicate-weights). Then, once we have the design object, we can filter the data to any subpopulation of interest (if needed). It is important to filter the data after creating the design object. This ensures that we are accurately accounting for the survey design in our calculations. Finally, we can use `group_by()`, `summarize()`, and other functions from the {survey} and {srvyr} packages to analyze the survey data by estimating means, totals, and so on. \index{Survey analysis process|)}\index{Design object|)} @@ -357,7 +357,7 @@ The functions in {srvyr} also play nicely with other tidyverse functions. For ex #| label: setup-dplyr-select towny %>% summarize(across(starts_with("population"), - ~mean(.x, na.rm=TRUE))) + ~mean(.x, na.rm = TRUE))) ``` ```{r} @@ -402,7 +402,7 @@ apistrat_des %>% api00_median = survey_median(api00)) ``` -At this time, the `.by` argument is `srvyr::summarize()` does not exist as it does in {dplyr}. An alternative way to do the grouped analysis on the `towny` data would be: +An alternative way to do grouped analysis on the `towny` data would be with the `.by` argument: ```{r} #| label: setup-dplyr-by-alt @@ -420,7 +420,7 @@ However, the `.by` syntax is not yet available in {srvyr}: apistrat_des %>% summarize(api00_mean = survey_mean(api00), api00_median = survey_median(api00), - .by=stype) + .by = stype) ``` \index{Functions in srvyr!survey\_median|)}