halveString {eatTools}R Documentation

Split string exactly in two parts

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

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

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

[Package eatTools version 0.6.0 Index]