What I want to do is create a combined tibble that contains all combination of cols, so my result should look like this:
# A tibble: 4 x 6
participant1 bodypart1 col1 participant2 bodypart2 col2
<chr> <chr> <dbl> <chr> <chr> <dbl>
1 left head 1 right head 3
2 left head 1 right body 4
3 left body 2 right head 3
4 left body 2 right body 4
library(tibble)
p1 <- tribble(
~participant, ~bodypart, ~col,
"left", "head", 1,
"left", "body", 2
)
p2 <- tribble(
~participant, ~bodypart, ~col,
"right", "head", 3,
"right", "body", 4
)
merge(p1,p2, all =TRUE, by = NULL)
#> participant.x bodypart.x col.x participant.y bodypart.y col.y
#> 1 left head 1 right head 3
#> 2 left body 2 right head 3
#> 3 left head 1 right body 4
#> 4 left body 2 right body 4