Getting started

Base R functions to wield regular expressions have been around since the project got started in the form of functions like gsub and grep. It seems, though, that a recent and popular approach is to use the stringr package (which is based on the excellent and  more extensive stringi package). Both because the format/argument order of the stringr functions are more consistent than their base R counterparts and because I would like to keep you abreast of popular trends in R programming, we'll be using this package to learn regex in R. Since all of the functions that we'll be using take a string (or vector of strings) to perform regex operations on as the first argument, we'll also be using the magrittr pipe operator (introduced ...

Get Data Analysis with R - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.