I want to perform the inverse of separate_rows(). i.e.:
# Create example data
data <- data.frame(x1 = c(1,1,3,3,5),
x2 = c('A','A','C','C','E'),
x3 = 6:10)
data
Which results in
x1 x2 x3
1 1 A 6
2 1 A 7
3 3 C 8
4 3 C 9
5 5 E 10
Somehow I expected a unite_rows() function in tidyr or dplyr to do this:
x1 x2 x3
1 1 A 6,7
3 3 C 8,9
5 5 E 10
But I couldn't find any similar. Should I combine cels using unite()? (it seems a dirty way to go)
unite(data, x2, x3, col = "x3", sep = ",")