Strings in R
Explore the key techniques for manipulating string data in R, such as counting characters, changing letter case, replacing patterns, detecting substrings, concatenating, and splitting strings. This lesson helps you effectively handle textual data for analysis and reporting.
Processing string (character) data
String manipulation is ubiquitous in datasets and is a critical skill for analysts to have. Data is often contained within blocks of text, requiring us to tease out the information contained in it with rigorous effort.
A range of techniques for string manipulation exists in data analysis. This lesson focuses on the most widely used methods.
Please note that some of the functions in this lesson come from the stringr library.
Find the length of strings
Finding the length of strings is helpful in filters and categorization.
There are different ways to see the number of characters in a string.
Both the built-in nchar() and the str_count() functions from the stringr library return the number of characters in a string.
# Use of nchar() function
myString <- "Education is ...