Session Ready
Exercise

Construct "or patterns" with glue

In the last two lessons you learned to create strings from other strings or vectors or lists, even data frames. Together with the knowledge you have about regular expressions, you are now able to create patterns for all these data types.

Using glue_collapse() you can concatenate the contents of a vector of the column of a data frame and create long patterns that would otherwise be very tedious and error prone to write from hand.

For this exercise, we have a vector users as an input. It is the result of a database export. It contains some rows of a database but also some other information that we don't care about. Using regular expressions we can match only the parts that we are interested in, in this case, the usernames.

Instructions
100 XP
  • Use the vector usernames to create a pattern that matches either of the three names in the vector.
  • Bind the three names together using the regular expression "or" character as a separator.