Stringr is a package in the tidyverse that deals with, well, strings. What are strings? Anything in your data frame that is text- or character-based. So, in the case of babynames, that’d be Name and Sex - Year, Prop and N are not strings.

Stringr allows for string manipulation across your entire dataset. If, for instance, we had a column of character data that repeatedly mis-spelled a name: Bryan instead of Brian, say - stringr could change every instance of Bryan into Brian in one line of code.

Let’s start playing around with stringr by creating a variable that is equal to a string:

library(stringr)

sentence <- c("hello", "this is a long sentence", NA)
Here are some functions from the stringr package that we can use to manipulate this sentence.