Learn R Programming

do (version 2.0.0.1)

col_split: Split A Vector into Columns

Description

Split A Vector into Columns

Usage

col_split(x, split, reg_expr, colnames, cat = TRUE)

Value

A dataframe with several columns.

Arguments

x

a vector

split

one or more characters. Split exactly

reg_expr

character. Split by regular expressions

colnames

optional. Column names for outcome

cat

logical, whether to show message

Examples

Run this code
x=c('1a2','3a4','4a4')
col_split(x,split='a')
col_split(x = x,reg_expr = '[a-z]')

#two splits
df=data.frame(result=c('A, B-C',
                       'A, C-D',
                       'E, F-G'))
col_split(x = df[,1],split = c(',','-'))

Run the code above in your browser using DataLab