splitText: splitText

Description Usage Arguments Examples

Description

This function splits the given column in the data.frame

Usage

1
splitText(vec, sep, part = 0, fixed = FALSE, fill = TRUE)

Arguments

vec

a vector of char objects

sep

character containing regular expression(s) (unless fixed = TRUE) to use for splitting.

part

the part of the split to return, when 0 returns all. defaults to 0.

fixed

logical. If TRUE match split exactly, otherwise use regular expressions. defaults to FALSE.

fill

logical. fill with NA when needed. defaults to TRUE.

Examples

1
2
3
4
5
6
7
splitText('hello2all4of222you', '\\d+')   # a vector ('hello','all', 'of', 'you')
splitText('hello.all.of.you', '.', fixed=TRUE)  # same as above
splitText('hello-all-of-you', '-')   # same as above
splitText('hello-all-of-you', '-', 2) # 'all'
splitText(c('all-2', 'any-3', 'never-4'), '-') # a data.frame with 2 columns
splitText(c('all-2', 'any-3', 'never-4-d'), '-') # The third column will be NA for the first two rows
splitText(c('all-2', 'any-3', 'never-4'), '-', 1) # a vector c('all', 'any', 'never')

etabari/ehsanr documentation built on Aug. 5, 2019, 4:07 p.m.