library(tidyr)
df <- lazy_dt(expand_grid(x = c("a", NA), y = c("b", NA)))
df
df %>% unite("z", x:y, remove = FALSE)
# Separate is almost the complement of unite
df %>%
unite("xy", x:y) %>%
separate(xy, c("x", "y"))
# (but note `x` and `y` contain now "NA" not NA)
Run the code above in your browser using DataLab