stringr 1.4.0

Mara Averick

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

You can install the released version from CRAN:

install.packages("stringr")
library(stringr)

New functions

Thanks to the hard work of John Harmon at Tidyverse Developer Day, stringr has three new functions.

str_starts() and str_ends() detect the presence or absence of patterns at the beginning or end of strings.

fruit <- c("apple", "banana", "pear", "pineapple")
str_starts(fruit, "p")
#> [1] FALSE FALSE  TRUE  TRUE
str_starts(fruit, "p", negate = TRUE)
#> [1]  TRUE  TRUE FALSE FALSE
str_ends(fruit, "e")
#> [1]  TRUE FALSE FALSE  TRUE
str_ends(fruit, "e", negate = TRUE)
#> [1] FALSE  TRUE  TRUE FALSE

The new str_to_sentence() function capitalizes strings with sentence case, like so:

str_to_sentence("the quick brown dog")
#> [1] "The quick brown dog"

Support for negate

str_subset(), str_detect(), and str_which() now have the negate argument, which is used to find the elements that do not match a pattern (as seen above in the str_starts() and str_ends() examples).

Acknowledgements

Thank you to everyone who contributed to this release: @AmeliaMN, @batpigandme, @beckymaust, @BenjaminLouis, @blablablerg, @bschneidr, @bwiernik, @ctmann, @damianooldoni, @dan-reznik, @denrou, @diegogarcilazo, @DieselAnalytics, @elisakreiss, @giovannikraushaar, @hadley, @hammer, @jennybc, @jimhester, @jonocarroll, @jonthegeek, @jrnold, @juanrocha, @kmace, @krlmlr, @osorensen, @paleolimbot, @pdelboca, @pgrandinetti, @PirateGrunt, @samhinshaw, @sastoudt, @seanpor, @yj-danielyang, and @yutannihilation.

Upcoming events
London
November 18 – 19, 2019
This two-day course will provide an overview of using R for supervised learning. You will learn how to build, visualize, test, and compare prediction-based models.
Miami, FL
December 16 – 18, 2019
Improve your tool building skills with this small hands-on workshop on a boat. All profits go to support the mission of the field school.