Stringi
Stringi is THE R package for fast, correct, consistent and convenient string/text processing in each locale and any native character encoding
Stringr
The stringr package is a wrapper for the R stringi package that provides consistent function names and error handling for string manipulation
Others
Example |
---|
Stringr provides more human-readable wrappers around the base r functions though as of dec 2014 the development version has a branch built on top of stringi mentioned below from question How to remove all whitespace from a string? |
If speed is your concern base r can be faster than stringr stringi the only consequence is that the na is turned into a literal nana here so the workaround is which makes base r about as fast as stringi and slightly faster than stringr in this case. i m mildly annoyed that paste converts na to na though that s already been addressed here on so . from question R string operation : How could i optimize this one? |
Stringr is newer based on stringi internally and is often even faster from question How to speed up this string split operation within data.table |
Since stringi runs slightly faster and has a larger set of functionalities i prefer to stick with stringi . see stringi vs stringr blog by hrbrmstr i tried to use base r data.frame syntax above where possible to avoid any confusion but if i were doing this for my self i d stick to the full data.table syntax as follows from question Replace multiple values using a reference table |
Stringr is based on stringi but stringi has more options from question R POS tagging and tokenizing in one go |