Fetching contributors…
Cannot retrieve contributors at this time
28 lines (25 sloc) 703 Bytes
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helper-colsplit.r
\title{Split a vector into multiple columns}
colsplit(string, pattern, names)
\item{string}{character vector or factor to split up}
\item{pattern}{regular expression to split on}
\item{names}{names for output columns}
Useful for splitting variable names that a combination of multiple
variables. Uses \code{\link{type.convert}} to convert each column to
correct type, but will not convert character to factor.
x <- c("a_1", "a_2", "b_2", "c_3")
vars <- colsplit(x, "_", c("trt", "time"))