Learn R Programming

splitstackshape (version 1.2.0)

concat.split.expanded: Split numeric concatenated values into their corresponding column position

Description

"Expand" concatenated numeric values to their relevant position in a data.frame.

Usage

concat.split.expanded(data, split.col, sep = ",",
    mode = NULL, drop = FALSE, fixed = FALSE, fill = NA)

Arguments

data
The source data.frame.
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").
drop
Logical. Should the original variable be dropped? Defaults to FALSE.
fixed
Used for strsplit for allowing regular expressions to be used.
fill
Desired "fill" value. Defaults to NA.

Value

  • A data.frame

See Also

concat.split, concat.split.list, concat.split.compact, concat.split.multiple, binaryMat, valueMat

Examples

Run this code
temp <- head(concat.test)
concat.split.expanded(temp, "Likes")
concat.split.expanded(temp, 4, ";")
concat.split.expanded(temp, 4, ";", mode = "value", drop = TRUE)

## Note the warning
concat.split.expanded(temp, "Siblings", drop = TRUE)

rm(temp)

Run the code above in your browser using DataLab