Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

colsplit

Split a vector into multiple columns


Description

Useful for splitting variable names that a combination of multiple variables. Uses type.convert to convert each column to correct type, but will not convert character to factor.

Usage

colsplit(string, pattern, names)

Arguments

string

character vector or factor to split up

pattern

regular expression to split on

names

names for output columns

Examples

x <- c("a_1", "a_2", "b_2", "c_3")
vars <- colsplit(x, "_", c("trt", "time"))
vars
str(vars)

reshape2

Flexibly Reshape Data: A Reboot of the Reshape Package

v1.4.4
MIT + file LICENSE
Authors
Hadley Wickham <h.wickham@gmail.com>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.