Unite multiple columns by pasting strings together
Convenience function to paste together multiple columns into one.
unite.(.df, col = "new_col", ..., sep = "_", remove = TRUE, na.rm = FALSE)
.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 |
test_df <- tidytable(a = c("a", "a", "a"), b = c("b", "b", "b"), c = c("c", "c", NA)) test_df %>% unite.("new_col", b, c) test_df %>% unite.("new_col", where(is.character)) test_df %>% unite.("new_col", b, c, remove = FALSE) test_df %>% unite.("new_col", b, c, na.rm = TRUE) test_df %>% unite.()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.