I know this might be a simple operation but I can't find a solution. I know it should be some form of group_by and sum or cumsum, but I cant figure out how. I want to plot a cumulative count of something by group over time. I have multiple rows per group and time that need to be counted (and some missing data). My dataset looks somewhat like this
df <- data.frame(group = c("A","A","A","A","B","B","B","C","C","C","C","C"),
time = c(1,1,2,3,1,2,2,1,2,2,3,3))
and I want this result:
group time count
A 1 2
A 2 3
A 3 4
B 1 1
B 2 3
C 1 1
C 2 3
C 3 5
I am usually use dplyr, but I am also happy with base R. How do I do that?