<- worldbankdata |>
df group_by(Income) |>
summarise(min = min(Electricity, na.rm=TRUE), max = max(Electricity, na.rm=TRUE), mean = mean(Electricity, na.rm=TRUE))
df
# A tibble: 5 × 4
Income min max mean
<fct> <dbl> <dbl> <dbl>
1 L 2.11 99.8 37.0
2 LM 3.81 100 78.8
3 UM 26.5 100 95.1
4 H 65.9 100 99.9
5 <NA> 17.8 100 89.7
<- ggplot(data=df, aes(x=Income, ymin=min, ymax=max)) +
a1 geom_errorbar(width=0.2, size=1, color="#d95f02") +
labs(title = "a1: geom_errorbar only")
<- ggplot(data=df, aes(x=Income, ymin=min, ymax=max)) +
a2 geom_errorbar(width=0.2, size=1, color="#d95f02") +
geom_point(data=df, mapping=aes(x=Income, y=mean), size=4, shape=21, fill="#1b9e77") +
labs(title = "a2: geom_errorbar and geom_point")
|a2 a1