From a9d34e950517a3c568e86d8cf8975b623bb5b9d6 Mon Sep 17 00:00:00 2001 From: Isabella Velasquez Date: Fri, 16 Aug 2024 13:42:43 -0700 Subject: [PATCH] Align code --- 08-communicating-results.Rmd | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/08-communicating-results.Rmd b/08-communicating-results.Rmd index 8a14569..5e01a5b 100644 --- a/08-communicating-results.Rmd +++ b/08-communicating-results.Rmd @@ -91,7 +91,7 @@ First, we can highlight important data elements in a sentence using plain langua This sentence provides key pieces of information in a straightforward way: - 1. [DATE]: Given that polling data are time-specific, providing the date of reference lets the audience know when these data were valid. + 1. [DATE\]: Given that polling data are time-specific, providing the date of reference lets the audience know when these data were valid. 2. Registered U.S. voters: This tells the audience who we surveyed, letting them know the population of interest. 3. XX%: This part provides the estimated percentage of people voting for a specific candidate for a specific office. 4. [YEAR] general election: Adding this gives more context about the election type and year. The estimate would take on a different meaning if we changed it to a primary election instead of a general election. @@ -172,8 +172,8 @@ trust_gov_gt2 <- trust_gov_gt %>% in the federal government, 2020") %>% tab_source_note("American National Election Studies, 2020") %>% tab_footnote( - "Question text: How often can you trust the federal government - in Washington to do what is right?" + 'Question text: "How often can you trust the federal government + in Washington to do what is right?"' ) %>% fmt_number(scale_by = 100, decimals = 1) @@ -311,9 +311,8 @@ anes_des_gtsum3 <- anes_des %>% in the federal government, 2020") %>% tab_source_note("American National Election Studies, 2020") %>% tab_footnote( - "Question text: How often can you trust - the federal government in Washington - to do what is right?" + 'Question text: "How often can you trust the federal government + in Washington to do what is right?"' ) ``` @@ -359,8 +358,8 @@ anes_des_gtsum4 <- anes_des %>% "American voter's trust in the federal government, 2020") %>% tab_source_note("American National Election Studies, 2020") %>% tab_footnote( - "Question text: How often can you trust the federal government - in Washington to do what is right?" + 'Question text: "How often can you trust the federal government + in Washington to do what is right?"' ) %>% tab_caption("Example of {gtsummary} table with trust in government estimates and average age") @@ -411,8 +410,8 @@ anes_des_gtsum5 <- anes_des %>% ) %>% tab_source_note("American National Election Studies, 2020") %>% tab_footnote( - "Question text: How often can you trust the federal government - in Washington to do what is right?" + 'Question text: "How often can you trust the federal government + in Washington to do what is right?"' ) ``` @@ -485,7 +484,7 @@ This is a great starting point: it appears that a higher percentage of people st ```{r} #| label: results-plot2 -#| fig.cap: "Bar chart of trust in government by chosen 2020 presidential candidate with colors" +#| fig.cap: "Bar chart of trust in government by chosen 2020 presidential candidate, with colors" #| fig.alt: "Bar chart with x-axis of 'VotedPres2020_selection' with labels Biden, Trump and Other. It has y-axis 'pct_trust' with labels 0.00, 0.05, 0.10 and 0.15. The chart is a bar chart with 3 vertical bars. Bar 1 (Biden) has a height of 0.12 and a color of strong reddish orange. Bar 2 (Trump) has a height of 0.17 and a color of vivid yellowish green. Bar 3 (Other) has a height of 0.06 and color of brilliant blue." pcolor <- anes_des_der %>% ggplot(aes(x = VotedPres2020_selection, @@ -514,7 +513,7 @@ pcol_error <- anes_des_der %>% pcol_error ``` -We can continue adding to our plot until we achieve our desired look. For example, we can eliminate the color legend, as it does not contribute meaningful information with `guides(fill = "none")`. We can also specify colors for `fill` using `scale_fill_manual()`. Inside this function, we provide a vector of values corresponding to the colors in our plot. These values are hexadecimal (hex) color codes, denoted by a leading pound sign `#` followed by six letters or numbers. The hex code `#0b3954` used below is dark blue. There are many tools online that help pick hex codes, such as https://htmlcolorcodes.com/. Additionally, Figure \@ref(fig:results-plot4) incorporates better labels for the x and y axes (`xlab()`, `ylab()`), a title (`labs(title=)`), and a footnote with the data source (`labs(caption=)`.) +We can continue adding to our plot until we achieve our desired look. For example, we can eliminate the color legend, as it does not contribute meaningful information with `guides(fill = "none")`. We can also specify colors for `fill` using `scale_fill_manual()`. Inside this function, we provide a vector of values corresponding to the colors in our plot. These values are hexadecimal (hex) color codes, denoted by a leading pound sign `#` followed by six letters or numbers. The hex code `#0b3954` used below is dark blue. There are many tools online that help pick hex codes, such as htmlcolorcodes.com. Additionally, Figure \@ref(fig:results-plot4) incorporates better labels for the x and y axes (`xlab()`, `ylab()`), a title (`labs(title=)`), and a footnote with the data source (`labs(caption=)`.) ```{r} #| label: results-plot4 @@ -541,5 +540,5 @@ pfull <- pfull ``` -What we have explored in this section are just the foundational aspects of {ggplot2}, and the capabilities of this package extend far beyond what we have covered. Advanced features such as annotation, faceting, and theming allow for more sophisticated and customized visualizations. The ggplot2 book by @ggplot2wickham is a comprehensive guide to learning more about this powerful tool. +What we have explored in this section are just the foundational aspects of {ggplot2}, and the capabilities of this package extend far beyond what we have covered. Advanced features such as annotation, faceting, and theming allow for more sophisticated and customized visualizations. The {ggplot2} book by @ggplot2wickham is a comprehensive guide to learning more about this powerful tool. \index{American National Election Studies (ANES)|)} \index{Plots|)} \ No newline at end of file