Reputation: 45
I am trying to use ggplot, to have a attractive plot between the year and codes.
My column with date looks like this 1990-10-20 ; 2000-10-28 ..
I wanted to plot all the year after 2000.
Below is the code, i have tried, could anyone help how i can look for year after 2000 and plot my graph.
count <- c %>%
group_by(Date, Code) %>%
summarise(count=n())
ggplot(count, aes(Date, count))+
geom_bar(stat = "identity")
Upvotes: 0
Views: 2312
Reputation: 2589
library(lubridate)
count %>%
filter(year(Date) > 2000) %>%
ggplot(aes(Date, count))+
geom_bar(stat = "identity")
For a range of years:
count %>% # BAD OBJECT NAME - RECITE 10 HAIL MARYS
filter(year(Date) >= 2012 & year(Date) <= 2014 <) %>%
ggplot(aes(Date, count))+
geom_bar(stat = "identity")
You could also see ?lubridate::between
for other ways, if your left and right limits are themselves dates.
Upvotes: 2