stringi: THE String Processing Package for R

stringi (pronounced “stringy”, IPA [strinɡi]) is THE R package for very fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.

—by Marek Gagolewski

Thanks to ICU, stringi fully supports a wide range of Unicode standards (see also this video).

stri_extract_all(regex="\\p{Emoji}",
    c("歡迎 欢迎! Χαίρετε! Bienvenidos! 😃❤🌍", "spam, spam, 🥓, 🍳, and spam"))
## [[1]]
## [1] "😃" "❤"  "🌍"
##
## [[2]]
## [1] "🥓" "🍳"

stri_count_fixed("ACATGAACGGGTACACACTG", "ACA", overlap=TRUE)
## [1] 3

stri_sort(c("cudný", "chladný", "hladný", "čudný"), locale="sk_SK")
## [1] "cudný"   "čudný"   "hladný"  "chladný"

stringi provides you with plenty of functions related to data cleansing, information extraction, and natural language processing:

  • string concatenation, padding, wrapping, and substring extraction,

  • pattern searching (e.g., with ICU Java-like regular expressions),

  • collation, sorting, and ranking,

  • random string generation,

  • string transliteration, case mapping and folding,

  • Unicode normalisation,

  • date-time formatting and parsing,

and many more.

stringi is among the most often downloaded R packages. downloads1 downloads2

You can obtain it from CRAN by calling:

install.packages("stringi")

stringi’s source code is hosted on GitHub. It is distributed under the open source BSD-3-clause license.

The package’s API was inspired by that of the early (pre-tidyverse; v0.6.2) version of Hadley Wickham’s stringr package (and since the 2015 v1.0.0 stringr is powered by stringi). Moreover, Hadley suggested quite a few new package features. The contributions from Bartłomiej Tartanus and many others is greatly appreciated. Thanks!

Also check out stringx for a set of wrappers around stringi with a base R-compatible API.

Reference Manual