Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

unite..html

Unite multiple columns by pasting strings together


Description

Convenience function to paste together multiple columns into one.

Usage

unite.(.df, col = "new_col", ..., 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

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

tidytable

Tidy Interface to 'data.table'

v0.6.1
MIT + file LICENSE
Authors
Mark Fairbanks [aut, cre], Abdessabour Moutik [ctb], Matt Carlson [ctb], Ivan Leung [ctb], Ross Kennedy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.