unite {tidyr} | R Documentation |
Convenience function to paste together multiple columns into one.
unite(data, col, ..., sep = "_", remove = TRUE)
data |
A data frame. |
col |
(Bare) name of column to add |
... |
Specification of columns to unite. Use bare variable names.
Select all variables between x and z with |
sep |
Separator to use between values. |
remove |
If |
separate()
, the complement.
unite_
for a version that uses regular evaluation
and is suitable for programming with.
library(dplyr) unite_(mtcars, "vs_am", c("vs","am")) # Separate is the complement of unite mtcars %>% unite(vs_am, vs, am) %>% separate(vs_am, c("vs", "am"))