I'm trying to add a combination of a gt table and a number of ggplot images to an email for sending to my team.
It's my understanding that to include a gt table in an email it needs to be converted to html using as_raw_html()
When I do this I can add the table to the email body but the column headers get all messed up. When I exclude the as_raw_html I only get the contents of the table and no structure.
Here's a reprex to show what I'm seeing. Any pointers on how I can get the table and images into the body would be greatly appreciated.
library(purrr)
library(ggplot2)
library(gt)
library(glue)
library(blastula)
generate_plots <- function(species) {
subset_data <- iris %>%
filter(Species == species)
bar_plot <- ggplot(subset_data, aes(x = Sepal.Length)) +
geom_bar(stat = "count") +
theme_minimal()
scatter_plot <- ggplot(subset_data, aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point() +
theme_minimal()
box_plot <- ggplot(subset_data, aes(y = Sepal.Length)) +
geom_boxplot() +
theme_minimal()
combined_charts <- cowplot::plot_grid(bar_plot, scatter_plot, box_plot, axis = "l", ncol = 1, align = "v", rel_heights = c(5,5,5))
blastula::add_ggplot(plot_object = combined_charts, width = 7, height = 10)
}
plots <- map(unique(iris$Species), generate_plots)
# CREATE GT TABLE
summary_table <- gt(iris) %>%
as_raw_html()