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

df_unite

Unite Multiple Columns into One


Description

Paste together multiple columns into one. Wrapper arround unite() that supports standard and non standard evaluation.

Usage

df_unite(data, col, ..., vars = NULL, sep = "_", remove = TRUE, na.rm = FALSE)

df_unite_factors(
  data,
  col,
  ...,
  vars = NULL,
  sep = "_",
  remove = TRUE,
  na.rm = FALSE
)

Arguments

data

a data frame

col

the name of the new column as a string or a symbol.

...

a selection of columns. One or more unquoted expressions (or variable names) separated by commas.

vars

a character vector containing the column names of interest.

sep

Separator to use between values.

remove

If TRUE, remove input columns from output data frame.

na.rm

If TRUE, missing values will be remove prior to uniting each value.

Functions

  • df_unite: Unite multiple columns into one.

  • df_unite_factors: Unite factor columns. First, order factors levels then merge them into one column. The output column is a factor.

Examples

# Non standard evaluation
head(ToothGrowth) %>%
 df_unite(col = "dose_supp", dose, supp)

# Standard evaluation
head(ToothGrowth) %>%
 df_unite(col = "dose_supp", vars = c("dose", "supp"))

rstatix

Pipe-Friendly Framework for Basic Statistical Tests

v0.7.0
GPL-2
Authors
Alboukadel Kassambara [aut, cre]
Initial release

We don't support your browser anymore

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