library(palmerpenguins)09-written-communication
Effective Written Communication
Course Announcements
Due Dates:
- Lab 05 due Fri 10/30 (11:59 PM)
- Mid-course survey “due” Fri 10/30 (11:59 PM)
- CS01 due Sunday (11:59 PM)
- report in repo
- General communication (Canvas)
- team eval survey
- Lecture Participation survey “due” after class
Note: - lab03 (check feedback on GH issue) and lab04 grades posted
Agenda
- Communicating for your audience
- Written Communication
- Visual Communication
Note: We’ll discuss oral communication closer to the end of the quarter, when you’ll have to present out loud.
Suggested Reading
- Quarto: Execution Options (code chunks & inline code)
- Quarto: HTML Basics and HTML Code Blocks
Consider your audience
What does this mean?
❓ What does it mean to “consider your audience?”
. . .
Simply: You do the work so they don’t have to.
. . .
…also the aesthetic-usability effect exists: people perceive polished, attractive work as easier to use (and are more forgiving of its flaws).
What’s the right level?
General Audience
✔ background
🚫 limit technical details
🎉 emphasize take-home

Technical Audience
⬇ limit background
💻 all-the-details
🎉 emphasize take-home

Considerations
- Platform: written? oral?
. . .
- Setting: informal? formal?
. . .
- Audience: technical? general?
Choose informative titles
In written reports: Balance b/w short and informative (goal: concise)
. . .
Avoid: “Analyzing NHANES”
Better: “Data from the NHANES study shows that diet is related to overall health”
. . .
On visualizations: emphasize the take-home! (what’s learned or what action to take)
. . .
Avoid: “Boxplot of gender”
Better: “Twice as many females as males included for analysis”
. . .
Avoid: “Tickets vs. Time”
Better: “Staff unable to respond to incoming tickets; need to hire 2 FTEs”
Effective Written Communication
Benefits of written communication
Your audience has time to process…but the explanation has to be there!
. . .
Visually: more on a single visualization
. . .
Yes, often there are different visualizations for reports/papers than for presentations/lectures.
When you have time to digest (read)

. . .
❓ What makes this an effective visualization for a written communication?
Source: Storytelling with data by cole nussbaumer knaflic
Written Explanations
- Visualizations should be explained/interpreted
- Analyses/Models should be explained
- should be clear what question is being answered
- what conclusion is being drawn
- and what numbers were used to draw that conclusion
Data Science Reports in .qmd
- As concise as possible
- Important information introduced before referenced (datasets, jargon, etc.)
- Necessary details (for your audience); nothing more
- Be sure that the rendered output contains what you intended (plots displayed; headers etc.)
- …and does NOT display stuff that doesn’t need to be there (messages/warnings suppressed, brainstorming, etc.)
- Typical Sections: Introduction/Background, Setup, Data, Analysis, Conclusion, References
Controlling HTML document settings
- Table of Contents
---
title: "Document Title"
format:
html:
toc: true
toc-depth: 3
---
. . .
- Theme
---
title: "Document Title"
format:
html:
theme: united
highlight-style: tango
---
. . .
- Figure Options
---
title: "Document Title"
format:
html:
fig-width: 7
fig-height: 6
---
. . .
- Code Folding
---
title: "Document Title"
format:
html:
code-fold: true
---
Controlling code chunk output
- Specified at the top of the chunk, one per line, with
#|
```{r}
#| label: chunk-label
#| results: hide
#| fig-height: 4
```. . .
eval: whether to execute the code chunkecho: whether to include the code in the outputinclude: false: run the code, but show nothing (code or output) in the rendered document. Great for setup chunks (e.g., loading packages)warning,message, anderror: whether to show warnings, messages, or errors in the rendered documentfig-widthandfig-height: control the width/height of plotsfig-cap: add a caption to a figure
. . .
- Controlling for the whole document (in the YAML):
---
title: "Document Title"
execute:
warning: false
message: false
---
Inline code: numbers in your text
Typing numbers into your text by hand means they go stale (or are just wrong!) when your data or analysis changes.
Instead, compute them with inline code:
The mtcars dataset includes `r nrow(mtcars)` cars, with an average fuel efficiency of `r round(mean(mtcars$mpg), 1)` mpg.. . .
…which renders as:
The mtcars dataset includes 32 cars, with an average fuel efficiency of 20.1 mpg.
. . .
The numbers in your conclusions are always the numbers from your analysis.
Editing & Proofreading
- Did you end up telling a story?
- Things missing?
- Things to delete?
. . .
- Do not fall in love with your words/code/plots
. . .
- Do spell check
- Do read it over before sending/presenting/submitting
Aside: Citing Sources
When are citations needed?
. . .
“We will be doing our analysis using two different data sets created by two different groups: Donohue and Mustard + Lott, or simply Lott”
. . .
“Right to Carry Laws refer to laws that specify how citizens are allowed to carry concealed handguns when they’re away from home without a permit”
. . .
“In this case study, we are examining the relationship between unemployment rate, poverty rate, police staffing, and violent crime rate.”
. . .
“In the United States, the second amendment permits the right to bear arms, and this law has not been changed since its creation in 1791.”
. . .
“The Right to Carry Laws (RTC) is defined as”a law that specifies if and how citizens are allowed to have a firearm on their person or nearby in public.””
. . .
Reminder: You do NOT get docked points for citing others’ work. You can be at risk of an Academic Integrity violation if you don’t. When in doubt, give credit.
Footnotes in .qmd
How to specify a footnote in text:
Here is some body text.[^1]How to include the footnote’s reference:
[^1]: This footnote will appear at the bottom of the page.Note: .bib files can be included with BibTeX references using the bibliography parameter in your YAML
Effective GenAI Strategies
❓ While generating your first draft, how can GenAI be helpful?
❓ After you have a first draft, how can GenAI be helpful?
❓ While completing your cs01, what to avoid with GenAI?
Effective Visual Communication
The Glamour of Graphics
- builds on top of the grammar (components) of a graphic
- considerations for the design of a graphic
- color, typography, layout
- going from 😬accurate to 😍effective
These ideas and slides are all modified from Will Chase’s rstudio::conf2020 slides/talk
. . .
The following example uses the penguins dataset from the palmerpenguins package (would have to be installed to run these.)
An Example…
ggplot(penguins, aes(x = species, fill = species)) +
geom_bar() +
labs(title = "Count vs. Species") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))
ggplot(penguins, aes(y = fct_rev(fct_infreq(species)), fill = species)) +
geom_bar() +
geom_text(stat='count', aes(label=after_stat(count)), hjust = 1.5, color = "white", size = 7) +
scale_x_continuous(expand = c(0, 0)) +
scale_fill_manual(values = c("#454545", rep("#adadad", 2))) +
labs(title = "Adelie Penguins are the most common in Antarctica",
subtitle = "Frequency of each penguin species studied near Palmer Station, Antarctica") +
theme_minimal(base_size = 14) +
theme(axis.text.x = element_blank(),
plot.title.position = "plot",
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.title = element_blank(),
legend.position = "none")
- Informative Titles
- Left Align Titles
- Borders & Backgrounds: 👎
- Organize & Remove/Lighten as much as possible
- Direct labels > legends
- Avoid head-tilting
A reminder that when you’re doing EDA, you’re going to generate a lot of plots. Don’t spend your time making all of them beautiful. Save that for the “editing” portion of your case study. Once you know which are needed to tell your story, add them in.
Tables are communication, too
penguins |>
group_by(species) |>
summarize(n = n(),
mean_mass = mean(body_mass_g, na.rm = TRUE),
mean_flipper = mean(flipper_length_mm, na.rm = TRUE))# A tibble: 3 × 4
species n mean_mass mean_flipper
<fct> <int> <dbl> <dbl>
1 Adelie 152 3701. 190.
2 Chinstrap 68 3733. 196.
3 Gentoo 124 5076. 217.
penguins |>
group_by(species) |>
summarize(n = n(),
mean_mass = mean(body_mass_g, na.rm = TRUE),
mean_flipper = mean(flipper_length_mm, na.rm = TRUE)) |>
arrange(desc(n)) |>
kable(col.names = c("Species", "N", "Body mass (g)", "Flipper length (mm)"),
digits = 0,
format.args = list(big.mark = ","),
caption = "Gentoo penguins are the largest, despite Adelie being most common") |>
kable_styling(full_width = FALSE)| Species | N | Body mass (g) | Flipper length (mm) |
|---|---|---|---|
| Adelie | 152 | 3,701 | 190 |
| Gentoo | 124 | 5,076 | 217 |
| Chinstrap | 68 | 3,733 | 196 |
- Informative caption (the take-home, like a plot title)
- Human-readable column names (with units!)
- Sensible rounding:
33.6234is rarely more useful than34 - Ordered rows
- No raw R output (
# A tibble: 3 x 4,<fct>,<dbl>) in a report
Recap
- Tailor communication for setting and audience
- Written communication has benefit of time; limitation of additional explanation
- Can you control your HTML output from a .qmd document?
- Can you use inline code to keep numbers in your text accurate?
- Do you know when to cite a source?
- Can you implement design choices when generating visualizations for communication?