StrSplitP: The improvement of 'strsplit'

Description Usage Arguments Value Examples

View source: R/strsplit.R

Description

This functions uses strsplit and adds the possibility to split and keep the delimiter after or before the given split. Or it can split between two given splits and keep both.

Usage

1
StrSplitP(x, split, type = "remove", perl = FALSE, ...)

Arguments

x

character vector, each element of which is to be split. Other inputs, including a factor, will give an error.

split

character vector (or object which can be coerced to such) containing regular expression(s) to use for splitting. If empty matches occur, in particular if split has length 0, x is split into single characters. If split has length greater than 1, it is recycled along x.

type

a character. Either to remove or keep the delimiter before, between or remove the split.

perl

logical.

...

other inputs passed along to strsplit.

Value

A list of the same length as x, the i-th element of which contains the vector

Examples

1
2
3
x <- c("3D/MON&SUN")
StrSplitP(x, "", type = "before")
x <- c("3D/MON&SUN")

stat545ubc-2021/functions-Jiangsissi720 documentation built on Dec. 23, 2021, 5:25 a.m.