Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## simulating sample data
- set.seed(.1073)
- my_df <- data.frame(my_dates = sample(seq(as.Date('2010-01-01'), as.Date('2016-12-31'), 1), 1000, replace = TRUE))
- ### aggregating + visualizing counts per month
- my_df %>%
- mutate(my_dates = round_date(my_dates, 'month')) %>%
- group_by(my_dates) %>%
- summarise(n_row = n()) %>%
- ggplot(aes(x = my_dates, y = n_row))+
- geom_bar(stat = 'identity', color = 'black',fill = 'slateblue', alpha = .5)+
- scale_x_date(date_breaks = 'months', date_labels = '%y-%b') +
- theme(axis.text.x = element_text(angle = 60, hjust = 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement