stringr API Reference
stringr — a tidyverse package providing a consistent, pipe-friendly API for string manipulation.
stringr functions
Consistent string manipulation functions from the stringr package, all prefixed with str_.
str_length(string) -> integerReturns the number of characters (code points) in each string of a character vector.
Returns: integer
str_sub(string, start = 1L, end = -1L) -> characterExtracts substrings by position. Negative indices count from the end.
Returns: character
str_detect(string, pattern) -> logicalReturns TRUE for each string that matches the pattern, FALSE otherwise.
Returns: logical
str_replace(string, pattern, replacement) -> characterReplaces the first match of pattern in each string with replacement.
Returns: character
str_to_lower(string) -> characterConverts strings to lowercase using Unicode rules.
Returns: character
str_split(string, pattern) -> listSplits each string by pattern, returning a list of character vectors.
Returns: list
str_c(..., sep = "") -> characterConcatenates strings element-wise. The stringr equivalent of paste0/paste.
Returns: character
str_trim(string, side = c("both", "left", "right")) -> characterTrims whitespace from the start, end, or both sides of each string.
Returns: character