Commercial enterprise offerings
Open source packages - Quarto, Shiny, and more
stringr 1.1.0
Written by Hadley Wickham
2016-08-24
I’m pleased to announce version 1.1.0 of stringr. stringr makes string manipulation easier by using consistent function and argument names, and eliminating options that you don’t need 95% of the time. To get started with stringr, check out the strings chapter in R for data science. Install it with:
install.packages("stringr")This release is mostly bug fixes, but there are a couple of new features you might care out.
- There are three new datasets,
fruit,wordsandsentences, to help you practice your regular expression skills:
str_subset(fruit, "(..)\\1")
#> [1] "banana" "coconut" "cucumber" "jujube" "papaya"
#> [6] "salal berry"
head(words)
#> [1] "a" "able" "about" "absolute" "accept" "account"
sentences[1]
#> [1] "The birch canoe slid on the smooth planks."- More functions work with
boundary():str_detect()andstr_subset()can detect boundaries, andstr_extract()andstr_extract_all()pull out the components between boundaries. This is particularly useful if you want to extract logical constructs like words or sentences.
x <- "This is harder than you might expect, e.g. punctuation!"
x %>% str_extract_all(boundary("word")) %>% .[[1]]
#> [1] "This" "is" "harder" "than" "you"
#> [6] "might" "expect" "e.g" "punctuation"
x %>% str_extract(boundary("sentence"))
#> [1] "This is harder than you might expect, e.g. punctuation!"str_view()andstr_view_all()create HTML widgets that display regular expression matches. This is particularly useful for teaching.
For a complete list of changes, please see the release notes.
Hadley Wickham
Chief Scientist, Posit
Hadley is Chief Scientist at Posit PBC, winner of the 2019 COPSS award, and a member of the R Foundation. He builds tools (both computational and cognitive) to make data science easier, faster, and more fun. His work includes packages for data science (like the tidyverse, which includes ggplot2, dplyr, and tidyr)and principled software development (e.g. roxygen2, testthat, and pkgdown). He is also a writer, educator, and speaker promoting the use of R for data science.