I have the dataframe df1. I need to concatenate row elements in X2 by similar X1 elements. Basically, if the values in df1 are the same, I need to concatenate the letters in X2. The output should look something like df2.
df1 <- data.frame(c(1, 1, 1, 2, 2, 2, 2, 3, 3, 4),
c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"))
names(df1) <- c("X1", "X2")
df2 <- data.frame(c(1, 2, 3, 4), c("A, B, C", "D, E, F, G", "H, I", "J"))
names(df2) <- names(df1)