rguides

Reference

String Functions

String handling and regex helpers.

  1. endsWith()

    Check if a string ends with a specified suffix in R.

  2. format()

    Format R objects for pretty printing, controlling decimal places and alignment.

  3. formatC()

    Format numbers using C-style formatting in R.

  4. grep()

    Search for matches to a pattern within character strings, returning indices.

  5. grepl()

    Search for matches to a pattern within character strings, returning a logical vector.

  6. gsub()

    Replace all occurrences of a pattern in a character string using regex or fixed matching.

  7. nchar()

    Get the length of a string in characters, bytes, or width units for display.

  8. startsWith()

    Check if a string starts with a specified prefix in R.

  9. strsplit()

    Split a character string into substrings based on a delimiter or pattern.

  10. sub()

    Replace the first occurrence of a pattern in a character string using regex or fixed matching.

  11. substring()

    Extract or replace substrings in a character vector using start and stop positions with flexible indexing.

  12. tolower()

    Convert character strings to lowercase in R.

  13. toupper()

    Convert character strings to uppercase in R.

  14. trimws()

    Remove leading and/or trailing whitespace from character strings. Essential for cleaning user input and text data before processing.