I would like to collapse multiples row conditions using tidyverse and here is my example
df <- data.frame(value = c(2,2,2,2,1,1,1,1,1,1),
name1 = c("a", "a", "b", "b", 'c', "d", "e", NA, NA, NA),
name2 = c("x", "x", "x", "x", "x", "x", "y", NA, NA, NA))
I would like to collapse rows saying that name1 is the same associated with name2 is the same, then those rows would be collapse into single row. Any suggestions for me?
My desired output like
value name1 name2
1 2 a x
2 2 b x
3 1 c x
4 1 d x
5 1 e y
6 1 <NA> <NA>
7 1 <NA> <NA>
8 1 <NA> <NA>