unembed | R Documentation |
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.
unembed(data, col, sep, fixed = TRUE)
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. |
a data frame with columns containing unique variables obtained by unembedding.
Courtesy to Aaron Wolen
## Not run: df <- data.frame(key = c("a", "a;b", "a;b;c"), val = 1:3) unembed(df, "key", ";") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.