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
Atlanta, GA
Oct 14-15
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.
London
Nov 18 - Nov 19
This two-day course will provide an overview of using R for supervised learning. The session will step through the process of building, visualizing, testing, and comparing models that are focused on prediction. The goal of the course is to provide a thorough workflow in R that can be used with many different regression or classification techniques. Case studies on real data will be used to illustrate the functionality and several different predictive models are illustrated. The class is taught by Max Kuhn.