Let's say I have 2 tables with columns of unequal length that I want to bind.
Here are the tables:
library(dplyr, warn.conflicts = FALSE)
table_1 <- tibble(var_1 = c(1, 2, NA, 3))
table_1
#> # A tibble: 4 x 1
#> var_1
#> <dbl>
#> 1 1
#> 2 2
#> 3 NA
#> 4 3
table_2 <- tibble(var_2 = c("a", "b", "c"))
table_2
#> # A tibble: 3 x 1
#> var_2
#> <chr>
#> 1 a
#> 2 b
#> 3 c
Is there a way I can bind these columns where the binding skips over the NA
s? I guess that would mean substituting an NA
in the shorter table where there is an NA
in the longer table.
So here's what I want to have in the end:
#> A tibble: 4 x 2
#> var_1 var_2
#> <dbl> <chr>
#> 1 1 a
#> 2 2 b
#> 3 NA NA
#> 4 3 c
Does that make any sense? There's probably a term for the type of joining I'm trying to do.