user6644063 user6644063 - 3 years ago 132
R Question

plot count of events against months from large dataset

I need to create a plot showing the count of events (y-axis) against months (x-axis), without considering the year the events occurred.

My data are stored into a

and I have got a column
showing the year-month-day of the event as follows:

df = read.table(text = 'ID Date
1 1975-10-01
1 1975-10-04
2 1975-11-03
2 1976-01-17
2 1980-02-04
3 1980-05-11
4 1983-03-09
4 1983-04-10', header = TRUE)

My real data.frame contains more observations but I hope that my data sample will be enough to solve my question.

Any suggestion?

Thanks for anyone who will help me.

Answer Source
df$month <- factor(lubridate::month(df$Date), 1:12,

ggplot(df, aes(month)) + geom_bar() + xlim(

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download