concat.split.expanded: Split Concatenated Values into their Corresponding Column...

Description Usage Arguments Value Author(s) See Also Examples

Description

"Expand" concatenated numeric or character values to their relevant position in a data.frame or data.table or create a binary representation of such data.

Usage

1
2
cSplit_e(data, split.col, sep = ",", mode = NULL, type = "numeric",
  drop = FALSE, fixed = TRUE, fill = NA)

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.

mode

Can be either "binary" (where presence of a number in a given column is converted to "1") or "value" (where the value is retained and not recoded to "1"). Defaults to "binary".

type

Can be either "numeric" (where the items being split are integers) or "character" (where the items being split are character strings). Defaults to "numeric".

drop

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

fixed

Used for base::strsplit() for allowing regular expressions to be used.

fill

Desired "fill" value. Defaults to NA.

Value

A data.frame or data.table depending on the source input.

Author(s)

Ananda Mahto

See Also

cSplit(), cSplit_l(), numMat(), charMat()

Examples

1
2
3
4
5
6
7
8
9
temp <- head(concat.test)
cSplit_e(temp, "Likes")
cSplit_e(temp, 4, ";", fill = 0)
 
## The old function name still works
concat.split.expanded(temp, "Likes")
concat.split.expanded(temp, 4, ";", fill = 0)
concat.split.expanded(temp, 4, ";", mode = "value", drop = TRUE)
concat.split.expanded(temp, "Siblings", type = "character", drop = TRUE)

splitstackshape documentation built on May 1, 2019, 8:20 p.m.