Split Data Frame String Column Into Multiple Columns
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.
SplitToCol(x, split = " ", fixed = TRUE, na.form = "", colnames = NULL)
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 |
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"
.
Andri Signorell <andri@signorell.net>
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"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.