SplitToCol {DescTools} | R Documentation |
Split Data Frame String Column Into Multiple Columns
Description
Splitting the string columns of a data frame into multiple columns requires a considerable number of codelines, which are condensed in this function for convenience.
Usage
SplitToCol(x, split = " ", fixed = TRUE, na.form = "", colnames = NULL)
Arguments
x |
a data frame containing the string columns to be splitted. |
split |
character vector (or object which can be coerced to such)
containing regular expression(s) (unless |
fixed |
logical. If |
na.form |
character, string specifying how |
colnames |
columnnames for the resulting data.frame. Will be recycled. Can easily be set to |
Value
A data.frame with all the columns splitted
A vector with the length of the number of columns of the data.frame containing the number of the found columns is returned as attribute namede "ncols"
.
Author(s)
Andri Signorell <andri@signorell.net>
See Also
Examples
d.frm <- data.frame(res1=c("2 [-3,5] **", "5 [-2,6] ***", "9 [-3,1]"),
res2=c("5 [6,8] **", "7 [-2,9]", "4 [3,5] **"),
stringsAsFactors=FALSE)
SplitToCol(d.frm, na.form="-", colnames=c("coef", "ci", "pval"))