I am unable to run the following on RStudio penguins %>% group_by(island) %>% drop_na(.) %>% summarise(mean_bill_length_mm = mean(bill_length_mm)) The error coming up is Error in drop_na(.) : could not find function "drop_na" What do I have to do to fix this?
Asked
Active
Viewed 4,657 times
-2
-
1Add `library(tidyr)` before your code – benson23 Mar 12 '22 at 13:40
1 Answers
-1
You can use this code:
library(palmerpenguins)
library(tidyverse)
penguins %>% group_by(island) %>% drop_na(.) %>% summarise(mean_bill_length_mm = mean(bill_length_mm))
Output:
# A tibble: 3 × 2
island mean_bill_length_mm
<fct> <dbl>
1 Biscoe 45.2
2 Dream 44.2
3 Torgersen 39.0

Quinten
- 35,235
- 5
- 20
- 53