Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Strings basics
Regular expressions
Modifying strings
Summary

Instruction

That was easy! Now we will try extracting some information from the countries vector. To check if a string contains a certain character or pattern, we can use the grepl() function. It looks like this:

grepl(pattern, vector)

The grepl() function will return a vector of TRUE or FALSE depending on whether it finds the pattern within the vector. For example, we could check which country name(s) contain the letter "a" using:

grepl("a", countries)

Exercise

Use the grepl() function to check which names in the countries vector contain the letter "r".