Apply a function on a given set of elements of a character string.
applyString(x, FUN, pos = NULL, pattern = NULL)
x | a character vector, or a vector to be coerced to a character vector. |
---|---|
FUN | the function to be applied, see |
pos | a vector indicating the elements position. |
pattern | a pattern see |
A character vector.
In case both pos
or pattern
, the latter is ignored.
applyString('cool', pos = 1:2, FUN = toupper)#> [1] "COol"#> [1] "cOOl" "prO"