Here is a df
id name
1 A
1 B
1 C
1 A
1 A
2 C
2 D
desired output with calculated column
id name calculated_column
1 A A,B,C
1 B A,B,C
1 C A,B,C
1 A A,B,C
1 B A,B,C
1 C A,B,C
1 B B,C
1 C B,C
1 A A
1 A A
1 A A
2 C C,D
2 D C,D
I thought I could maybe create a sequence column and do a concatenation, but I'm really stuck.
I want to use dplyr, but I'm open to other suggestions.
df <- df %>%
group_by(id) %>%
arrange(date) %>%
mutate(calculated_column = ... ?)