4

Working with Strings

Strings, in the programming world, are textual information: a single letter, a word, a phrase, or, more generally, anything that comes in between single or double quotes will be understood as a string by the computer once it is assigned to a variable. See the following code and comments:

# If not assigned to a variable, a text is just a comment.
"This is a text."
# These are strings
my_string1 <- "a"
my_string2 <- "Hello, World! I am learning!"
my_string1 <- "42"

The manipulation of strings is a good skill to have due to the amount of good data that is found on the internet in textual format. Natural Language Processing (NLP) is one of the largest areas in data science, and a lot of it relies on wrangling strings.

Most ...

Get Data Wrangling with R 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.