Task 11: Strings and grep


Using global regular expression print (grep) and regular expressions (regex) to find character string patterns is a valuable tool in data analysis and is available with all operating systems and many different programming languages. It is a powerful tool once it is understood. The recently developed library(stringr) package makes these tools much easier to use. The three tasks below can be completed in many different ways. As a challenge, my code to complete this entire task less than 10 lines.


  • [ ] Use the readr::read_lines() function to read in each string - randomletters.txt and randomletters_wnumbers.txt
  • [ ] With the randomletters.txt file, pull out every 1700 letter (e.g. 1, 1700, 3400, …) and find the quote that is hidden - the quote ends with a period
  • [ ] With the randomletters_wnumbers.txt file, find all the numbers hidden and convert those numbers to letters using the letters order in the alphabet to decipher the message
  • [ ] With the randomletters.txt file, remove all the spaces and periods from the string then find the longest sequence of vowels.
  • [ ] Save your .R script to your repository and be ready to share your code solution at the beginning of class