String Functions
String handling and regex helpers.
endsWith()
Check if a string ends with a specified suffix in R.
endsWith(x, suffix) format()
Format R objects for pretty printing, controlling decimal places and alignment.
format(x, trim = FALSE, digits = NULL, nsmall = 0, scientific = NA, ...) formatC()
Format numbers using C-style formatting in R.
formatC(x, digits = 1, format = 'd', width = NULL, flag = '', mode = NULL, big.mark = '') grep()
Search for matches to a pattern within character strings, returning indices.
grep(pattern, x, value = FALSE, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE) grepl()
Search for matches to a pattern within character strings, returning a logical vector.
grepl(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE) gsub()
Replace all occurrences of a pattern in a character string using regex or fixed matching.
gsub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE) nchar()
Get the length of a string in characters, bytes, or width units for display.
nchar(x, type = "chars", keepNA = FALSE) startsWith()
Check if a string starts with a specified prefix in R.
startsWith(x, prefix) strsplit()
Split a character string into substrings based on a delimiter or pattern.
strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE) sub()
Replace the first occurrence of a pattern in a character string using regex or fixed matching.
sub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE) substring()
Extract or replace substrings in a character vector using start and stop positions with flexible indexing.
substring(text, first, last = .Machine$integer.max) tolower()
Convert character strings to lowercase in R.
tolower(x) toupper()
Convert character strings to uppercase in R.
toupper(x) trimws()
Remove leading and/or trailing whitespace from character strings. Essential for cleaning user input and text data before processing.
trimws(x, which = c("both", "left", "right"), whitespace = "[[:space:]]")