Skip to content

Commit

Permalink
Small edits to chapter 08
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelasq committed Aug 19, 2024
1 parent a9d34e9 commit fdc396d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions 08-communicating-results.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ After finishing the analysis and modeling, we proceed to the task of communicati

Before beginning any dissemination of results, consider questions such as:

- How are we presenting results? Examples include a website, print, or other media. Based on the media type, we might limit or enhance the use of graphical representation.
- How are we presenting results? Examples include a website, print, or other media. Based on the medium, we might limit or enhance the use of graphical representation.
- What is the audience's familiarity with the study and/or data? Audiences can range from the general public to data experts. If we anticipate limited knowledge about the study, we should provide detailed descriptions (we discuss recommendations later in the chapter).
- What are we trying to communicate? It could be summary statistics, trends, patterns, or other insights. Tables may suit summary statistics, while plots are better at conveying trends and patterns.
- Is the audience accustomed to interpreting plots? If not, include explanatory text to guide them on how to interpret the plots effectively.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -311,8 +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?"
)
```

Expand Down Expand Up @@ -358,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")
Expand Down Expand Up @@ -410,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?"
)
```

Expand Down Expand Up @@ -466,7 +466,7 @@ anes_des_der
```
\index{Functions in srvyr!summarize|)} \index{Functions in srvyr!survey\_mean|)}

Now, we can begin creating our chart with {ggplot2}. First, we set up our plot with `ggplot()`. Next, we define the data points to be displayed using aesthetics, or `aes`. Aesthetics represent the visual properties of the objects in the plot. In the following example, we create a bar chart of the percentage of people who usually trust the government by who they voted for in the 2020 election. To do this, we want to have who they voted for on the x-axis (`VotedPres2020_selection`) and the percent they usually trust the government on the y-axis (`pct_trust`.) We specify these variables in `ggplot()` and then indicate we want a bar chart with `geom_bar()`. The resulting plot is displayed in Figure \@ref(fig:results-plot1).
Now, we can begin creating our chart with {ggplot2}. First, we set up our plot with `ggplot()`. Next, we define the data points to be displayed using aesthetics, or `aes`. Aesthetics represent the visual properties of the objects in the plot. In the following example, we create a bar chart of the percentage of people who usually trust the government by who they voted for in the 2020 election. To do this, we want to have who they voted for on the x-axis (`VotedPres2020_selection`) and the percent they usually trust the government on the y-axis (`pct_trust`). We specify these variables in `ggplot()` and then indicate we want a bar chart with `geom_bar()`. The resulting plot is displayed in Figure \@ref(fig:results-plot1).

```{r}
#| label: results-plot1
Expand All @@ -480,7 +480,7 @@ p <- anes_des_der %>%
p
```

This is a great starting point: it appears that a higher percentage of people state they usually trust the government among those who voted for Trump compared to those who voted for Biden or other candidates. Now, what if we want to introduce color to better differentiate the three groups? We can add `fill` under `aesthetics`, indicating that we want to use distinct colors for each value of `VotedPres2020_selection`. In this instance, Biden and Trump are displayed in different colors (shades in the print version of this book) in Figure \@ref(fig:results-plot2).
This is a great starting point: it appears that a higher percentage of people state they usually trust the government among those who voted for Trump compared to those who voted for Biden or other candidates. Now, what if we want to introduce color to better differentiate the three groups? We can add `fill` under `aesthetics`, indicating that we want to use distinct colors for each value of `VotedPres2020_selection`. In this instance, Biden and Trump are displayed in different colors in Figure \@ref(fig:results-plot2).

```{r}
#| label: results-plot2
Expand Down Expand Up @@ -513,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 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, since the color legend does not contribute meaningful information, we can eliminate it 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
Expand Down

0 comments on commit fdc396d

Please sign in to comment.