Skip to contents

Advanced Substrings of a Character Vector

Usage

cutstr(x, split = "", n = Inf)

Arguments

x

a character vector.

split

a length 1 character vector. Used to split x.

n

integer; maximum length of output string.

Value

A character vector of the same length as x.

Examples

x <- "This is an example sentence"
# Return x as-is
cutstr(x)
#> [1] "This is an example sentence"

# Same as substr
cutstr(x, n = 15)
#> [1] "This is an exam"

# Break between words
cutstr(x, split = " ", n = 15)
#> [1] "This is an"