Skip to contents

This is a wrapper around tidyr::separate_wider_regex() that allows to split a column into multiple columns. The column contains so-called delimiter separated values (DSV) and the values are extracted using regular expressions.

Usage

separate_wider_dsv(
  data,
  col,
  names,
  ...,
  patterns = NULL,
  delim = "_",
  prefix = NULL,
  suffix = NULL
)

Arguments

data

A data frame.

col

<tidy-select> Column to separate.

names

Names of the new columns. Use NA if you want a component not to be in the output.

...

Additional arguments passed to tidyr::separate_wider_regex().

patterns

Regular expressions to extract the values from the column. If NULL, the pattern will match any character non-greedily. The length of the vector must be equal to the number of new columns.

delim

Delimiter used in the column to separate different pieces of values.

prefix, suffix

Prefix and suffix to be removed from the target column to retrieve the values.

Value

A data frame with the separated columns.