#Hi ! does anyone have any idea why (the hell) this code doesn't work?:
penguins %>% filter(species == "Gentoo") %>% select(bill_length_mm) %>% mean(na.rm = TRUE)
# R generates this output:
[1] NA
Warning message:
In mean.default(., na.rm = TRUE) :
argument is not numeric or logical: returning NA
# And why this code works good?:
adelie_penguins <- filter(penguins, species == "Adelie")
mean(adelie_penguins$bill_length_mm, na.rm = TRUE)
penguins %>% filter(species == "Gentoo") %>% select(bill_length_mm) %>% max(na.rm = TRUE)
Returns:
[1] 38.79139 (mean)
[1] 59.6 (max)
#Thanks a lot! hope it was clear