Learn R Programming

splitstackshape (version 1.0)

concat.split.multiple: Split concatenated cells in a data.frame and optionally reshape the output

Description

This is an extended version of the concat.split.compact function that allows the user to split multiple columns at once and optionally use the Reshape function to convert the data.frame into a "long" format.

Usage

concat.split.multiple(data, split.cols, seps = ",",
    direction = "wide")

Arguments

data
The source data.frame.
split.cols
A vector of columns that need to be split.
seps
A vector of the separator character used in each column. If all columns use the same character, you can enter that single character.
direction
The desired form of the resulting data.frame, either 'wide' or 'long'. Defaults to 'wide'.

Value

  • A data.frame. If direction = "long", a data.frame with additional attributes created by the reshape function in base R.

See Also

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

Examples

Run this code
temp <- head(concat.test)
concat.split.multiple(temp, split.cols = c("Likes", "Hates", "Siblings"),
                      seps = c(",", ";", ","))
concat.split.multiple(temp, split.cols = c("Likes", "Siblings"),
                      seps = ",", direction = "long")
rm(temp)

Run the code above in your browser using DataLab