Split Concatenated Cells into a List Format

Share:

Description

Takes a column in a data.frame or data.table with multiple values, splits the values into a list, and returns a new data.frame or data.table.

Usage

1
cSplit_l(data, split.col, sep = ",", drop = FALSE, fixed = FALSE)

Arguments

data

The source data.frame or data.table.

split.col

The variable that needs to be split (either name or index position).

sep

The character separating each value. Can also be a regular expression.

drop

Logical. Should the original variable be dropped? Defaults to FALSE.

fixed

Used for strsplit for allowing regular expressions to be used.

Value

A data.frame or data.table with the concatenated column split and added as a list.

Author(s)

Ananda Mahto

See Also

concat.split, concat.split.compact, concat.split.expanded, concat.split.multiple

Examples

1
2
3
4
5
6
7
8
temp <- head(concat.test)
str(cSplit_l(temp, "Likes"))
cSplit_l(temp, 4, ";")

## The old function name still works
str(concat.split.list(temp, "Likes"))
concat.split.list(temp, 4, ";")
concat.split.list(temp, 4, ";", drop = TRUE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.