Loading required package: pacman
Warning: package 'pacman' was built under R version 4.3.2
New names:
• `Group` -> `Group...1`
• `Group` -> `Group...3`
For the March 2024 Pick Your Passion, I decided to explore sugar intake. I have a tremendous sweet tooth - shove a piece of cheesecake in my face and my body will force me to eat it. Over the years, I’ve become aware of the negative effect that too much sugar can have on my body. So, I decided to take a quick glance at the intake of added sugar around the world and within the United States.
Increased sugar intake contributes to weight gain & obesity, increased risk of diabetes, and an increased risk of heart disease. In America, we tend to have an obsession with soft drinks. According to the USDA 43% of our added sugar intake can be attributed to sugar-sweetened beverages or desserts & sweet snacks.
Within our household, we have deliberately limited sugary drinks as a way to cut down on calories and the “invisible” sugar intake.
The USDA recommends a diet limiting the intake of added sugars to about 12 teaspoons per day. Currently, Americans consume about 17 teaspoons per day.
In the upcoming slides, you will see a brief exploration around sugar consumption across the globe as well as a look at how added sugar consumption has changed in the United States in recent years.
Loading required package: pacman
Warning: package 'pacman' was built under R version 4.3.2
New names:
• `Group` -> `Group...1`
• `Group` -> `Group...3`
The world loves a sweet treat. But which countries consume the most sugar? Can you guess where the United States is on this chart?
num_levels <- length(unique(usda_whr$country))
#have to repeat colors so all are filled
repeated_colors <- rep(unique(ghibli::ghibli_palette("PonyoMedium")), length.out = num_levels)
ggplot(usda_whr %>%
dplyr::select(country,consumption_tsp_day,healthy_life_expectancy_at_birth),
aes(x = consumption_tsp_day, y = healthy_life_expectancy_at_birth, color = country)) +
geom_point() +
labs(x = "Consumption (tsp) Per Day",
y = "Healthy Life Expectancy",
title = "Sugar Consumption Across the Globe",
subtitle = "Sugar Consumption against Healthy Life Expectancy At Birth for Select Countries from the USDA",
caption = "Data from
https://finance.yahoo.com/news/20-countries-highest-sugar-consumption-211427408.html
and
https://worldhappiness.report/ed/2023/#appendices-and-data") +
theme_minimal() +
theme(legend.position = "none") +
scale_color_manual(values = repeated_colors, guide = "none")scatterdata <- usda_whr %>%
dplyr::select(country,consumption_tsp_day,healthy_life_expectancy_at_birth) %>%
dplyr::mutate(consumption_tsp_day_log = log(consumption_tsp_day))
highlight_color = "#E75B64FF"
ggplot(scatterdata,
aes(x = consumption_tsp_day, y = healthy_life_expectancy_at_birth, color = country)) +
geom_point(color = "gray") + # All points in gray
geom_point(data = subset(scatterdata, country == "United States"), color = highlight_color, size = 3) + # Highlight United States
annotate("text", x = scatterdata$consumption_tsp_day[scatterdata$country == "United States"], y = scatterdata$healthy_life_expectancy_at_birth[scatterdata$country == "United States"], label = "United States", color = highlight_color, hjust = 0, vjust = 1.5) + # Annotate "United States"
labs(x = "Consumption (tsp) Per Day",
y = "Healthy Life Expectancy",
title = "Sugar Consumption vs. Healthy Life Expectancy at Birth",
subtitle = "Where is the United States?",
caption = "Data from \nhttps://finance.yahoo.com/news/20-countries-highest-sugar-consumption-211427408.html \nand \nhttps://worldhappiness.report/ed/2023/#appendices-and-data"
) +
theme_minimal() +
theme(
plot.subtitle = element_text(color = highlight_color), # Apply custom color to subtitle
axis.text.x = element_text(color = "gray", size = 9), # Adjust x-axis label color and size
axis.text.y = element_text(color = "gray", size = 9),
axis.title.x = element_text(color = "black", size = 11),
axis.title.y = element_text(color = "black", size = 11)
)The scales are a bit lopsided. Here, we log the consumption of sugar per day to standardize the scale.
ggplot(scatterdata,
aes(x = consumption_tsp_day_log, y = healthy_life_expectancy_at_birth, color = country)) +
geom_point(color = "gray") + # All points in gray
geom_point(data = subset(scatterdata, country == "United States"), color = highlight_color, size = 3) + # Highlight United States
annotate("text", x = scatterdata$consumption_tsp_day_log[scatterdata$country == "United States"], y = scatterdata$healthy_life_expectancy_at_birth[scatterdata$country == "United States"], label = "United States", color = highlight_color, hjust = 0, vjust = 1.5) + # Annotate "United States"
labs(x = "Consumption (tsp) Per Day (log)",
y = "Healthy Life Expectancy",
title = "Sugar Consumption vs. Healthy Life Expectancy at Birth",
subtitle = "Where is the United States?",
caption = "Data from \nhttps://finance.yahoo.com/news/20-countries-highest-sugar-consumption-211427408.html \nand \nhttps://worldhappiness.report/ed/2023/#appendices-and-data"
) +
theme_minimal() +
theme(
plot.subtitle = element_text(color = highlight_color), # Apply custom color to subtitle
axis.text.x = element_text(color = "gray", size = 9), # Adjust x-axis label color and size
axis.text.y = element_text(color = "gray", size = 9),
axis.title.x = element_text(color = "black", size = 11),
axis.title.y = element_text(color = "black", size = 11)
)So, this looks strange, right? The more sugar you consume, the higher your healthy life expectancy??
lm_fit <- lm(healthy_life_expectancy_at_birth ~ consumption_tsp_day_log, data = scatterdata)
rsquared <- summary(lm_fit)$r.squared
ggplot(scatterdata,
aes(x = consumption_tsp_day_log, y = healthy_life_expectancy_at_birth, color = country)) +
geom_point(color = "gray") + # All points in gray
geom_point(data = subset(scatterdata, country == "United States"), color = highlight_color, size = 3) + # Highlight United States
annotate("text", x = scatterdata$consumption_tsp_day_log[scatterdata$country == "United States"],
y = scatterdata$healthy_life_expectancy_at_birth[scatterdata$country == "United States"],
label = "United States", color = highlight_color, hjust = 0, vjust = 1.5) + # Annotate "United States"
labs(x = "Consumption (tsp) Per Day (log)",
y = "Healthy Life Expectancy",
title = "Sugar Consumption vs. Healthy Life Expectancy at Birth",
subtitle = "More Sugar = Longer Life????",
caption = "Data from \nhttps://finance.yahoo.com/news/20-countries-highest-sugar-consumption-211427408.html \nand \nhttps://worldhappiness.report/ed/2023/#appendices-and-data"
) +
geom_smooth(method = "lm", se = FALSE, color = "#1c77a3") +
annotate("text", x = max(scatterdata$consumption_tsp_day_log, na.rm = TRUE),
y = max(scatterdata$healthy_life_expectancy_at_birth, na.rm = TRUE),
label = paste("R-squared:", round(rsquared, 3)),
hjust = 1,
vjust = 1,
color = "#1c77a3") + # Annotate R-squared value
theme_minimal() +
theme(
plot.subtitle = element_text(color = highlight_color), # Apply custom color to subtitle
axis.text.x = element_text(color = "gray", size = 9), # Adjust x-axis label color and size
axis.text.y = element_text(color = "gray", size = 9),
axis.title.x = element_text(color = "black", size = 11),
axis.title.y = element_text(color = "black", size = 11)
)`geom_smooth()` using formula = 'y ~ x'
I am NOT suggesting that we should eat more sugar to live longer. Don’t take this somewhat spurious correlation to heart.
Here is the same data from the previous slide in table format
usda_tbl <- usda_whr %>%
dplyr::mutate(population_M = round(population/1000000,2),
year = as.character(year)) %>%
dplyr::select(country,population_M,year,
consumption_kg_percapita = consumption_kg_capita_rounded,
healthy_life_expectancy_at_birth,consumption_tsp_day,source
)
#colors for continuous scale
c_color_red <- c("#e75b64","#ec6e73","#f07f82","#f49091","#f7a0a0","#fab0b0","#fcc0bf","#fed0cf","#ffe0df","#ffefef","#FFFFFF")
c_color_blue <- c("#1c77a3","#3b84ac","#5392b6","#699fbf","#7fadc8","#94bad2","#a9c8db","#bfd5e4","#d4e3ed","#e9f1f6","#FFFFFF")
usda_tbl %>%
dplyr::arrange(desc(population_M)) %>%
gt() %>%
fmt_number(decimals = 2) %>%
# fmt_integer(population_M) %>%
cols_label_with(
fn = ~ janitor::make_clean_names(., case = "title")
) %>%
data_color(
columns = consumption_tsp_day,
palette = c_color_red,
reverse = TRUE
) %>%
data_color(
columns = healthy_life_expectancy_at_birth,
palette = c_color_blue,
reverse = TRUE
) %>%
# tab_style(
# style = cell_fill(color = "gray95"),
# locations = cells_body(columns = c(population_M))
# ) %>%
tab_style(
locations = cells_body(columns = country),
style = cell_text(weight = "bold")
) %>%
opt_interactive(
use_filters = TRUE,
use_compact_mode = TRUE,
# use_pagination = FALSE,
# use_pagination_info = FALSE,
use_text_wrapping = FALSE,
use_resizers = TRUE,
use_highlight = TRUE,
use_page_size_select = TRUE
) %>%
tab_header(
title = md("**Sugar Consumption** and **Healthy Life Expectancy** Data"),
subtitle = "For countries present in the Yahoo Finance dataset referenced"
) %>%
opt_align_table_header(align = "left") %>%
tab_options(heading.padding = px(1),
quarto.use_bootstrap = TRUE) %>%
tab_footnote(
footnote = "Healthy Life Expectancy calculated by the World Happiness Report.",
locations = cells_column_labels(columns = consumption_kg_percapita)
) %>%
tab_footnote(
footnote = "Population values obtained from the 2021 census.",
locations = cells_column_labels(columns = population_M)
) %>%
opt_footnote_marks(marks = c("†", "‡")) %>%
opt_footnote_spec(spec_ref = "i", spec_ftr = "i") %>%
tab_source_note(source_note = md(
"**Sources**
Consumption data from the `Yahoo Finance` datasets available [here](https://finance.yahoo.com/news/20-countries-highest-sugar-consumption-211427408.html)
Healthy Life Expectancy data from the `World Happiness Report` available [here](https://worldhappiness.report/ed/2023/#appendices-and-data) "
))Globally, the United States is seemingly middle-of-the-road concerning sugar intake, but how have our behaviors changed over time? Overall, it looks like our sugar intake is increasing.
##Sugar Consumption Comparisons ----
ggplot(sugar_data %>% dplyr::filter(group_3 == "Total Overall"), aes(x = year,
y = added_sugar_tsp,
fill = group_1,
label - added_sugar_tsp)) +
geom_bar(stat = "identity", position = "dodge",
show.legend = FALSE) +
geom_text(aes(label = added_sugar_tsp),position = position_dodge(width = 0.1), vjust = 1) +
facet_wrap(~group_1, scales = "free_y") +
labs(
title = "Sugar Consumption Over Time<br>
<span style = 'font-size:10pt;'>Estimates of <span style = 'color:#e75b64;'>overall</span>
sugar consumption by group derived by the Economic Research Service.</span>",
x = "Year of Estimate",
y = "Added Sugar (tsp/day)",
fill = "Variable"
) +
theme_minimal() +
ghibli::scale_fill_ghibli_d("PonyoMedium", direction = -1) +
theme(
plot.title = element_textbox_simple(
size = 14, lineheight = 1, padding = margin(0,0,5,0)
)
)The Middle Class loves sugar, apparently.
ggplot(sugar_data %>% dplyr::filter(group_3 == "At Home"), aes(x = year,
y = added_sugar_tsp,
fill = group_1,
label - added_sugar_tsp)) +
geom_bar(stat = "identity", position = "dodge",
show.legend = FALSE) +
geom_text(aes(label = added_sugar_tsp),position = position_dodge(width = 0.1), vjust = 1) +
facet_wrap(~group_1, scales = "free_y") +
labs(
title = "Sugar Consumption Over Time<br>
<span style = 'font-size:10pt;'>Estimates of <span style = 'color:#e75b64;'>at home</span>
sugar consumption by group derived by the Economic Research Service.</span>",
x = "Year of Estimate",
y = "Added Sugar (tsp/day)",
fill = "Variable"
) +
theme_minimal() +
ghibli::scale_fill_ghibli_d("PonyoMedium", direction = -1) +
theme(
plot.title = element_textbox_simple(
size = 14, lineheight = 1, padding = margin(0,0,5,0)
)
)Sugar intake away from home has seemingly declined among middle class Americans.
ggplot(sugar_data %>% dplyr::filter(group_3 == "Total Away From Home"), aes(x = year,
y = added_sugar_tsp,
fill = group_1,
label - added_sugar_tsp)) +
geom_bar(stat = "identity", position = "dodge",
show.legend = FALSE) +
geom_text(aes(label = added_sugar_tsp),position = position_dodge(width = 0.1), vjust = 1) +
facet_wrap(~group_1, scales = "free_y") +
labs(
title = "Sugar Consumption Over Time<br>
<span style = 'font-size:10pt;'>Estimates of sugar consumpation <span style = 'color:#e75b64;'>away from home</span>
by group derived by the Economic Research Service.</span>",
x = "Year of Estimate",
y = "Added Sugar (tsp/day)",
fill = "Variable"
) +
theme_minimal() +
ghibli::scale_fill_ghibli_d("PonyoMedium", direction = -1) +
theme(
plot.title = element_textbox_simple(
size = 14, lineheight = 1, padding = margin(0,0,5,0)
)
)Added sugar intake has increased in the United States. Globally, the United States is closer to the median than the upper quartile in sugar intake. A healthy diet is complex and requires a balance of fats, sugars, and many other nutrients and should not be judged solely on sugar intake. However, with the increase in added sugar at home for Americans, we need to be cognizant of the potential negative side effects of consuming more sweet treats on our bodies.
Happy (and healthy) eating!
R Packages
(Wickham et al. 2023; Wickham 2016; Wilke and Wiernik 2022; Henderson 2024; Iannone et al. 2023; Firke 2023)
Data Sources