I have a dataset that looks like this
ID|Type
1 "Basketball"
1 "Baseball"
2 "Basketball"
2 "Football"
3 "Boxing"
4 "Boxing"
4 "Wrestling"
4 "Handball"
4 "Hockey"
I would like to create a dataset that looks like this
ID| Type|observation
1 "Basketball" 1
1 "Baseball" 2
2 "Basketball" 1
2 "Football" 2
3 "Boxing" 1
4 "Boxing" 1
4 "Wrestling" 2
4 "Handball" 3
4 "Hockey" 4
I'm stuck after this part and tried doing this
df %>%
group_by(ID) %>%
1:nrow(df)