Learn R Programming

miscset (version 1.0.0)

strpart: Split String and Return Part

Description

Return the nth part of a splitted string.

Usage

strpart(x, split, n, ..., roll = F)

Arguments

x
Character vector.
split
Regular expression splitting strings.
n
Number of part to extract.
...
Arguments passed to strsplit.
roll
Logical, if to use the last when less than maximum parts.

Value

A character vector of the extracted parts.

See Also

strsplit

Examples

Run this code
#

strpart(c("abc","abcb","abc"), "", 4)
strpart(c("abc","abcb","abc"), "", 4, roll=TRUE)

#

Run the code above in your browser using DataLab