how can we plot time with multiple groups in r?

Maybe try this aggregating your data:

df %>% mutate(Date=as.Date(Date,'%d/%m/%Y'),
              Year=format(Date,'%Y')) %>%
  group_by(Year,Group) %>%
  summarise(N=n()) %>%
  ggplot(aes(x=factor(Year), y=Group, size = N,color=Group)) +


enter image description here

Some data used:

df <- structure(list(Group = c("Group1", "Group1", "Group2", "Group3", 
"Group1", "Group1"), Date = c("29/12/2008", "29/12/2008", "29/12/2008", 
"10/05/2009", "10/05/2009", "10/05/2009")), class = "data.frame", row.names = c(NA, 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top