col_split: Split A Vector into Columns

View source: R/col_split.R

col_splitR Documentation

Split A Vector into Columns

Description

Split A Vector into Columns

Usage

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

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

Value

A dataframe with several columns.

Examples

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(',','-'))

do documentation built on Sept. 12, 2024, 6:27 a.m.