© Thomas Mailund 2019Thomas MailundR Data Science Quick Referencehttps://doi.org/10.1007/978-1-4842-4894-2_8
8. Working with Strings: stringr
package gives you functions for string manipulation. The package will be loaded when you load the tidyverse
You can also load the package alone using
Counting String Patterns
The str_count() function
counts how many tokens a string contain, where tokens, for example, can be characters or words.
By default, str_count()
will count the number of characters in a string.
strings <- c(
"Give me an ice cream",
"Get yourself an ice cream",
"We are all out of ice creams",
"I scream, you scream, everybody loves ice cream.", ...