SplitToCol.Rd
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)
a data frame containing the string columns to be splitted.
character vector (or object which can be coerced to such)
containing regular expression(s) (unless fixed = TRUE
)
to use for splitting. If empty matches occur, in particular if
split
has length 0, x
is split into single characters.
If split
has length greater than 1, it is re-cycled along
x
.
logical. If TRUE
match split
exactly, otherwise
use regular expressions. Has priority over perl
.
character, string specifying how NAs
should be specially formatted. Default is a blank ""
.
columnnames for the resulting data.frame. Will be recycled. Can easily be set to ""
if no columnnames should be set.
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"
.
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"))
#> coef ci pval coef ci pval
#> 1 2 [-3,5] ** 5 [6,8] **
#> 2 5 [-2,6] *** 7 [-2,9] -
#> 3 9 [-3,1] - 4 [3,5] **