unembed: Splits rows based on values embedded in a column based on a...

View source: R/unembed.R

unembedR Documentation

Splits rows based on values embedded in a column based on a separator

Description

Splits rows based on values embedded in a column based on a separator. E.g. one row with "ABC11 /// BCD22" variable in a column in will be split into two separate entries (" /// " separator), creating two ABC11 and BCD22 rows with other values equal to the original row.

Usage

unembed(data, col, sep, fixed = TRUE)

Arguments

data

a data.frame object, with a column containing values with multiple variables.

col

column name containing values with multiple variables.

sep

character/regular expression to split a column by

fixed

logical. If TRUE (default), match split exactly, otherwise use regular expressions.

Value

a data frame with columns containing unique variables obtained by unembedding.

Note

Courtesy to Aaron Wolen

Examples

## Not run: 
df <- data.frame(key = c("a", "a;b", "a;b;c"), val = 1:3)
unembed(df, "key", ";")

## End(Not run)

mdozmorov/MDmisc documentation built on Aug. 24, 2022, 9:18 a.m.