Skip to content

stringr 1.0.0

Compare
Choose a tag to compare
@hadley hadley released this 30 Apr 13:17
  • stringr is now powered by stringi instead of base R regular expressions. This improves unicode and support, and makes most operations considerably faster. If you find stringr inadequate for your string processing needs, I highly recommend looking at stringi in more detail.

  • stringr gains a vignette, currently a straight forward update of the article that appeared in the R Journal.

  • str_c() now returns a zero length vector if any of its inputs are zero length vectors. This is consistent with all other functions, and standard R recycling rules. Similarly, using str_c("x", NA) now yields NA. If you want "xNA", use str_replace_na() on the inputs.

  • str_replace_all() gains a convenient syntax for applying multiple pairs of pattern and replacement to the same vector:

    input <- c("abc", "def")
    str_replace_all(input, c("[ad]" = "!", "[cf]" = "?"))
  • str_match() now returns NA if an optional group doesn't match (previously it returned ""). This is more consistent with str_extract() and other match failures.

  • New str_subset() keeps values that match a pattern. It's a convenient wrapper for x[str_detect(x)] (#21, @jiho).

  • New str_order() and str_sort() allow you to sort and order strings in a specified locale.

  • New str_conv() to convert strings from specified encoding to UTF-8.

  • New modifier boundary() allows you to count, locate and split by character, word, line and sentence boundaries.

  • The documentation got a lot of love, and very similar functions (e.g. first and all variants) are now documented together. This should hopefully make it easier to locate the function you need.

  • ignore.case(x) has been deprecated in favour of fixed|regexp|coll(x, ignore.case = TRUE), perl(x) has been deprecated in favour of regexp(x).

  • str_join() is deprecated, please use str_c() instead.