⚠️There's a newer version (1.5.1) of this package. Take me there.

stringr

Strings are not glamorous, high-profile components of R, but they do play a big role in many data cleaning and preparations tasks. R provides a solid set of string operations, but because they have grown organically over time, they can be inconsistent and a little hard to learn. Additionally, they lag behind the string operations in other programming languages, so that some things that are easy to do in languages like Ruby or Python are rather hard to do in R.

The stringr package aims to remedy these problems by providing a clean, modern interface to common string operations. More concretely, stringr:

  • Uses consistent functions and argument names.

  • Simplifies string operations by eliminating options that you don't need 95% of the time.

  • Produces outputs than can easily be used as inputs. This includes ensuring that missing inputs result in missing outputs, and zero length inputs result in zero length outputs.

  • Is built on top of stringi which uses the ICU library to provide fast, correct implementations of common string manipulations

Installation

To get the current released version from CRAN:

install.packages("stringr")

To get the current development version from github:

# install.packages("devtools")
devtools::install_github("hadley/stringr")

Piping

stringr provides the pipe, %>%, from magrittr to make it easy to string together sequences of string operations:

letters %>%
  str_pad(5, "right") %>%
  str_c(letters)

Copy Link

Version

Down Chevron

Install

install.packages('stringr')

Monthly Downloads

999,491

Version

1.1.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 19th, 2016

Functions in stringr (1.1.0)