Matching patterns

Author

Jeffrey R. Stevens

Published

March 10, 2023

For these exercises, we’ll use the dog breed traits data set.

  1. Load tidyverse, import dog_breed_traits_clean.csv to traits, and extract the breed column into an object called breeds that randomly shuffles the breeds using 12 as a seed for randomization.
# >
  1. View the breeds ending with the letter “s”.
# >
  1. Create a logical vector showing whether breeds have at least two words in their names.
# >
  1. Extract the hounds (but don’t release them). That is, return a vector of all breeds that include the string “hound” or “Hound”.
# >
  1. Extract the breeds that include the following pattern “<wildcard>ep”.
# >
  1. OK, maybe English Buttdragger isn’t the proper AKC name for this breed. Replace English Buttdragger with English Chaser.
# >
  1. Replace all instances of “English” with “British” and then return the breeds that include “English” or “British” in them (to check our work).
# >
  1. Extract the Spaniels and then separate the breed names into different strings for each word and create a matrix out of it.
# >