df <- CJ(x = c("a", NA), y = c("b", NA))
df
# Treat missing value as NA, default
df %>% unite("z", x:y, remove = FALSE)
# Treat missing value as character "NA"
df %>% unite("z", x:y, na2char = TRUE, remove = FALSE)
# the unite has memory, "z" would not be removed in new operations
# here we remove the original columns ("x" and "y")
df %>% unite("xy", x:y,remove = TRUE)
# Select all columns
iris %>% as.data.table %>% unite("merged_name",".")
Run the code above in your browser using DataLab