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()
andstr_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 thestri_flatten()
function, which flattens a character vector into a single string. This is equivalent topaste(x, collapse = "-")
but it is a bit more explicit in your code –str_flatten()
always returns a single string.str_remove()
andstr_remove_all()
, which wrapstr_replace()
andstr_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.
Contributors
Thanks to all of the community members who helped with this release by contributing code and filing issues: @alanault, @AlunHewinson, @amhrasmussen, @andreypanchenko, @austin3dickey, @bachlaw, @bpasanek, @cderv, @ClaytonJY, @cwickham, @danielsjf, @dchiu911, @dhicks, @dhodge, @djrobust, @dracodoc, @duarteguilherme, @etienne-s, @ewallace, @florisvdh, @frootor, @geotheory, @gonulate, @guiastrennec, @hongshaoyang, @IndrajeetPatil, @IngaPa, @jameshowison, @jennybc, @jerryfuyu0104, @jimvine, @jonmcalder, @jonocarroll, @landroni, @lozalojo, @m0nhawk, @mgirlich, @mplourde, @msgoussi, @nokome, @novakowd, @nthun, @pgensler, @richierocks, @shapiromatron, @Shians, @sibojan, @sieste, @simonthelwall, @skanskan, @stephlocke, @swvanderlaan, @thorvall, @tjmahr, @tomwwagstaff, @yeedle, @yutannihilation, @zapashcanon, and @zhaoy.