From this question we see a simple geom_line
in the answer.
library(dplyr)
BactData %>% filter(year(Date) == 2017) %>%
ggplot(aes(Date, Svartediket_CB )) + geom_line()
If we change geom_line
to geom_bar
we may expect to see a bar plot, but instead
Error: stat_count() must not be used with a y aesthetic.
But it works if we add stat = "identity"
, like so
library(dplyr)
BactData %>% filter(year(Date) == 2017) %>%
ggplot(aes(Date, Svartediket_CB )) + geom_bar(stat = "identity")
Why doesn't geom_bar
work without stat = "identity"
- i.e. what is the purpose of stat = "identity"
?