this should be fairly simple but I just can't get my head around it.
I have the following dataframe,
df <- data.frame(Type = c(rep('type1',3),rep('type2',2),rep('type3',3)))
I want to aggregate, and then start with a 1-value, and increase it once the group changes, having the following output:
df2 <- data.frame(Type = c(rep('typea',3),rep('typeb',2),rep('typec',3)), new_var = c(1,1,1,2,2,3,3,3))
Long story short, I am looking to count groups and add them to the right of the dataframe.