applyString: Apply a function on character strings

View source: R/applyString.R

applyStringR Documentation

Apply a function on character strings

Description

Apply a function on a given set of elements of a character string.

Usage

applyString(x, FUN, pos = NULL, pattern = NULL)

Arguments

x

a character vector, or a vector to be coerced to a character vector.

FUN

the function to be applied, see base::lapply().

pos

a vector indicating the elements position.

pattern

a pattern see base::gregexpr().

Value

A character vector.

Note

In case both pos or pattern, the latter is ignored.

Examples

applyString('cool',  pos = 1:2, FUN = toupper)
applyString(c('cool', 'pro'),  pattern = 'o', FUN = toupper)

letiR/letiRmisc documentation built on Sept. 11, 2022, 12:43 a.m.