unite {tidytable} | R Documentation |
Unite multiple columns by pasting strings together
Description
Convenience function to paste together multiple columns into one.
Usage
unite(.df, col = ".united", ..., sep = "_", remove = TRUE, na.rm = FALSE)
Arguments
.df |
A data.frame or data.table |
col |
Name of the new column, as a string. |
... |
Selection of columns. If empty all variables are selected.
|
sep |
Separator to use between values |
remove |
If TRUE, removes input columns from the data.table. |
na.rm |
If TRUE, NA values will be not be part of the concatenation |
Examples
df <- tidytable(
a = c("a", "a", "a"),
b = c("b", "b", "b"),
c = c("c", "c", NA)
)
df %>%
unite("new_col", b, c)
df %>%
unite("new_col", where(is.character))
df %>%
unite("new_col", b, c, remove = FALSE)
df %>%
unite("new_col", b, c, na.rm = TRUE)
df %>%
unite()
[Package tidytable version 0.11.1 Index]