I'm trying to add the median value into the tooltip in geom_boxplot_interactive(tooltip = )
, without having to calculate it for each grouping and joining it to the dataset.
I have tried to see if something in stat_summary()
, stat or middle would work. But no luck so far.
library(ggplot2)
library(ggiraph)
data("mpg")
# View(mpg)
p <- ggplot(mpg, aes(x = class, y = hwy, tooltip = class)) +
geom_boxplot_interactive()
ggiraph(code = print(p))
# ggiraph(ggobj = p + geom_boxplot_interactive(aes(tooltip = data$median))
p <- ggplot(mpg, aes(x = drv, y = hwy, tooltip = class, fill = class)) +
geom_boxplot_interactive(outlier.colour = "red") +
guides(fill = "none") + theme_minimal()
girafe(ggobj = p)
This works if I have the median value for each group in the dataset, but I am trying to avoid this if possible.