Learn R Programming

qdap (version 0.2.5)

colsplit2df: Wrapper for colSplit that Returns Dataframe(s)

Description

colsplit2df - Wrapper for colSplit that returns a dataframe. lcolsplit2df - Wrapper for colsplit2df designed for qdap lists that returns a list dataframes.

Usage

colsplit2df(dataframe, splitcol = 1, new.names = NULL,
    sep = ".", keep.orig = FALSE)

  lcolsplit2df(qdap.list, keep.orig = FALSE)

Arguments

dataframe
A dataframe with a column that has been pasted together.
splitcol
The name of the column that has been pasted together.
new.names
A character vector of new names to assign to the columns. Default attempts to extract the original names before the paste.
sep
The character that used in paste2 to paste the columns.
keep.orig
logical. If TRUE the original pasted column will be retained as well.
qdap.list
A qdap list object that contains dataframes with a leading paste2 column.

Value

  • colsplit2df - returns a dataframe with the paste2 column split into new columns. lcolsplit2df - returns a list of dataframes with the paste2 column split into new columns.

Warning

This will strip the class of the qdap object.

See Also

colSplit, paste2

Examples

Run this code
CO2$`Plant&Type&Treatment` <- paste2(CO2[, 1:3])
CO2 <- CO2[, -c(1:3)]
head(CO2)
head(colsplit2df(CO2, 3))
head(colsplit2df(CO2, 3, qcv(A, B, C)))
head(colsplit2df(CO2, 3, qcv(A, B, C), keep.orig=TRUE))
head(colsplit2df(CO2, "Plant&Type&Treatment"))
CO2 <- datasets::CO2

(x <- question_type(DATA$state, list(DATA$sex, DATA$adult)))
ltruncdf(x)
z <- lcolsplit2df(x)
ltruncdf(z)

Run the code above in your browser using DataLab