From c83a0756a0e8f1889d34ed0a41be9410d815382c Mon Sep 17 00:00:00 2001 From: rpowell22 Date: Sun, 3 Mar 2024 19:18:02 -0500 Subject: [PATCH] Add styler chunks to the beginning of each chapter. --- 05-descriptive-analysis.Rmd | 6 ++++++ 07-modeling.Rmd | 6 ++++++ 08-communicating-results.Rmd | 1 + 09-reproducible-data.Rmd | 8 +++++++- 10-specifying-sample-designs.Rmd | 6 ++++++ 13-ncvs-vignette.Rmd | 6 ++++++ 14-ambarom-vignette.Rmd | 6 ++++++ 92-AppendixC.Rmd | 6 ++++++ 8 files changed, 44 insertions(+), 1 deletion(-) diff --git a/05-descriptive-analysis.Rmd b/05-descriptive-analysis.Rmd index e6fa4236..aa3fb616 100644 --- a/05-descriptive-analysis.Rmd +++ b/05-descriptive-analysis.Rmd @@ -1,5 +1,11 @@ # Descriptive Analyses in {srvyr} {#c05-descriptive-analysis} +```{r} +#| label: desc-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + ::: {.prereqbox-header} `r if (knitr:::is_html_output()) '### Prerequisites {- #prereq5}'` ::: diff --git a/07-modeling.Rmd b/07-modeling.Rmd index d8a91e1b..e00d8800 100644 --- a/07-modeling.Rmd +++ b/07-modeling.Rmd @@ -1,5 +1,11 @@ # Modeling {#c07-modeling} +```{r} +#| label: model-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + ::: {.prereqbox-header} `r if (knitr:::is_html_output()) '### Prerequisites {- #prereq7}'` ::: diff --git a/08-communicating-results.Rmd b/08-communicating-results.Rmd index 00544871..14d07d8d 100644 --- a/08-communicating-results.Rmd +++ b/08-communicating-results.Rmd @@ -3,6 +3,7 @@ # Communicating results {#c08-communicating-results} ```{r} +#| label: results-styler #| include: false knitr::opts_chunk$set(tidy = 'styler') ``` diff --git a/09-reproducible-data.Rmd b/09-reproducible-data.Rmd index 85659210..4264fdad 100644 --- a/09-reproducible-data.Rmd +++ b/09-reproducible-data.Rmd @@ -1,5 +1,11 @@ # Reproducible Research {#c09-reprex-data} +```{r} +#| label: reprex-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + Reproducing a data analysis's results is a crucial aspect of any research. First, reproducibility serves as a form of quality assurance. If we pass an analysis project to another person, they should be able to run the entire project from start to finish and obtain the same results. They can critically assess the methodology and code while detecting potential errors. Enabling the verification of our analysis is another goal of reproducibility. When someone else is able to check our results, it ensures the integrity of the analyses by determining that the conclusions are not dependent on a particular person running the code or workflow on a particular day or in a particular environment. Not only is reproducibility a key component in ethical and accurate research, but it is also a requirement for many scientific journals. These journals now require authors to make code, data, and methodology transparent and accessible to other researchers who wish to verify or build on existing work. @@ -46,7 +52,7 @@ The {here} package enables easy file referencing. In a project-based workflow, a ```{r} #| eval: false -#| label: project-file-example +#| label: reprex-project-file-example anes <- read_csv(here::here("data", "anes2020_clean.csv")) ``` diff --git a/10-specifying-sample-designs.Rmd b/10-specifying-sample-designs.Rmd index 2463f1cb..133bef19 100644 --- a/10-specifying-sample-designs.Rmd +++ b/10-specifying-sample-designs.Rmd @@ -2,6 +2,12 @@ # Specifying sample designs and replicate weights in {srvyr} {#c10-specifying-sample-designs} +```{r} +#| label: samp-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + ::: {.prereqbox-header} `r if (knitr:::is_html_output()) '### Prerequisites {- #prereq3}'` ::: diff --git a/13-ncvs-vignette.Rmd b/13-ncvs-vignette.Rmd index 580aa124..ca491799 100644 --- a/13-ncvs-vignette.Rmd +++ b/13-ncvs-vignette.Rmd @@ -2,6 +2,12 @@ # National Crime Victimization Survey Vignette {#c13-ncvs-vignette} +```{r} +#| label: ncvs-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + ::: {.prereqbox-header} `r if (knitr:::is_html_output()) '### Prerequisites {- #prereq9}'` ::: diff --git a/14-ambarom-vignette.Rmd b/14-ambarom-vignette.Rmd index 040f6c39..3f099f3e 100644 --- a/14-ambarom-vignette.Rmd +++ b/14-ambarom-vignette.Rmd @@ -1,5 +1,11 @@ # AmericasBarometer Vignette {#c14-ambarom-vignette} +```{r} +#| label: ambarom-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + ::: {.prereqbox-header} `r if (knitr:::is_html_output()) '### Prerequisites {- #prereq10}'` ::: diff --git a/92-AppendixC.Rmd b/92-AppendixC.Rmd index db3f4a94..b894cf98 100644 --- a/92-AppendixC.Rmd +++ b/92-AppendixC.Rmd @@ -1,5 +1,11 @@ # Importing survey data into R +```{r} +#| label: readr-styler +#| include: false +knitr::opts_chunk$set(tidy = 'styler') +``` + To analyze a survey, we need to import the survey data into R. This process is often referred to as importing, loading, or reading in data. Survey files come in different formats depending on the software used to create them. One of the many advantages of R is the flexibility in handling various data formats, regardless of their file extensions. Here are examples of common public-use survey file formats we may encounter: * Delimiter-separated text files