I'm newbie to R. I need to aggregate the data by group with sequence. I'm adding my data frame. first two column is given data, I have to mutate third column.
df <- data.frame(id = c(rep("a",3), rep("b",2), rep("c", 4)),
value = c("x", "z", "p", "q", "q", "m", "n", "x", "y"),
reqd = c("x,z,p", "z,p", "p", "q,q","q", "m,n,x,y", "n,x,y", "x,y", "y"))
I had aggregated by group but its not correct
df_2 <- df[,1:2] %>%
group_by(id) %>%
mutate(reqd2 = paste(value, collapse = ","))