powered by
Convenience function to paste together multiple columns.
unite(data, col, ..., sep = "_", remove = TRUE, na.rm = FALSE)
A data.frame with the columns passed via ... pasted together in a new column.
data.frame
...
A data.frame.
character(1) or symbol(1). The name of the new column.
character(1)
symbol(1)
The columns to unite.
character(1). Separator to use between the values.
logical(1). If TRUE, remove the input columns from the output data.frame.
logical(1)
TRUE
logical(1). If TRUE, missing values will be remove prior to uniting each value.
df <- data.frame(x = c("a", "a", NA, NA), y = c("b", NA, "b", NA)) df df %>% unite("z", x:y, remove = FALSE) # To remove missing values: df %>% unite("z", x:y, na.rm = TRUE, remove = FALSE)
Run the code above in your browser using DataLab