Chapter 13. Manipulating Strings
Strings (character
data) often need to be constructed or deconstructed to identify observations, preprocess text, combine information or satisfy any number of other needs. R
offers functions for building strings, like paste
and sprintf
. It also provides a number of functions for using regular expressions and examining text data, although for those purposes it is better to use Hadley Wickham’s stringr
package.
13.1. paste
The first function new R
users reach for when putting together strings is paste
. This function takes a series of strings, or expressions that evaluate to strings, and puts them together into one string. We start by putting together three simple strings.
> paste ...
Get R for Everyone: Advanced Analytics and Graphics 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.