How would I create a label that accounts for two points? In this example I am interested in making a label that is the sum of the the "6" and the "8" bars and has a line pointing to each of them. Currently I have:
library(tidyverse)
library(ggrepel)
mtcars %>%
group_by(cyl) %>%
summarise(mpg = median(mpg)) %>%
ggplot(aes(factor(cyl), mpg, label = mpg)) +
geom_bar(stat = "identity") +
geom_text_repel()
The label would be loosely equivalent to code below and would go somewhere above and between the 6 and the 8 bars with lines pointing to each of the bars.
label <- mtcars %>%
group_by(cyl) %>%
summarise(mpg = median(mpg)) %>%
filter(cyl >= 6) %>%
summarise (mpg = sum(mpg))