halveString: Split string exactly in two parts

Description Usage Arguments Value Author(s) Examples

Description

strsplit splits a string according to a specific sign. The number of occurrences of the splitting sign defines the number of splits. halveString allows to split the string in only two parts, no matter how often the splitting sign occurs.

Usage

1
halveString (string, pattern, first = TRUE )

Arguments

string

A character vector.

pattern

character vector (or object which can be coerced to such) to use for splitting.

first

Logical: Relevant if the pattern occurs more than one time in the string. Defines whether the first (default) or last occurrence is used for splitting.

Value

A data.frame with two columns

Author(s)

Sebastian Weirich

Examples

1
2
3
4
str <- c("John_Bolton", "Richard_Milhouse_Nixon", "Madonna")
strsplit(str, split = "_")
halveString(str, pattern = "_")
halveString(str, pattern = "_", first=FALSE)

eatTools documentation built on Nov. 10, 2021, 5:07 p.m.