stringr 1.3.0

We are happy to announce that stringr 1.3.0 is now on CRAN. stringr provides a cohesive set of functions designed to make working with strings as easy as possible. For a complete list of changes, please see the release notes.

What’s new?

  • Two new wrappers from the glue package: str_glue() and str_glue_data(). If you haven’t heard of glue, you’re in for a treat! Glue lets you easily interpolate data into strings.

    name <- "Chet Manley"
    str_glue("My name is {name}.")
    #> My name is Chet Manley.

    Since stringr is loaded with tidyverse, this means that you can now access glue’s functionality without loading another package.

  • str_flatten(), a wrapper for the stri_flatten() function, which flattens a character vector into a single string. This is equivalent to paste(x, collapse = "-") but it is a bit more explicit in your code – str_flatten() always returns a single string.

  • str_remove() and str_remove_all(), which wrap str_replace() and str_replace_all() for removing patterns from strings.

  • str_squish(), which removes whitespace from the left and right sides of strings, and converts multiple spaces or space-like characters from the middle of strings into a single space.

    str_squish("\n\nString \t\nwith all \tthis     \rspace   in it.\n\n")
    #> [1] "String with all this space in it."

API changes

The long deprecated str_join(), ignore.case(), and perl() functions have been removed. You may see Error : object ‘ignore.case’ is not exported by 'namespace:stringr' during package build.

Contents
Upcoming events
Sydney, Australia
May 1-2
You should take this workshop if you have experience programming in R and want to learn how to tackle larger scale problems. The class is taught by Hadley Wickham, Chief Scientist at RStudio.
San Francisco, CA
Jan 27-30
rstudio::conf 2020 covers all things RStudio, including workshops to teach you the tidyverse, and talks to show you the latest and greatest features.