unite.: Unite multiple columns by pasting strings together

View source: R/unite.R

unite.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. tidyselect compatible.

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()

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.