Hello everyone,
this is hopefully a simple one. Let's say I have
test <- tribble(
~id1, ~id2, ~something, ~different,
1, 2, "nyan", "cat",
2, 1, "blue", "elephant",
3, 4, "squeaky", "mouse",
4, 3, "hard", "rock"
)
I want to end up with a tibble that gets rid of rows with duplicate ids, but contain all the information. So in this case, my result would look like this:
tribble(
~id1, ~id2, ~something_1, ~different_1, ~something_2, ~different_2,
1, 2, "nyan", "cat", "blue", "elephant",
3, 4, "squeaky", "mouse", "hard", "rock"
)
What's the best way to achieve this? I tried working with left_join:
left_join(test, test, by = c("id1" = "id2"), suffix = c("_1", "_2"))
...but then I still don't know how to get rid of the "duplicate" rows (and I have "id2" in there twice...).
Thank you!