library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.1.0 ✓ dplyr 1.0.5
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(palmerpenguins)
penguins <- penguins
Why do the points not join?
penguins %>%
group_by(species) %>%
summarise(mean = mean(body_mass_g, na.rm = TRUE)) %>%
ggplot(aes(x = species, y = mean)) +
geom_point() +
geom_line()
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
penguins %>%
group_by(species) %>%
summarise(mean = mean(body_mass_g, na.rm = TRUE)) %>%
ggplot(aes(x = species, y = mean, group = "species")) +
geom_point() +
geom_line()