Announcements

  • Today’s office hours: 8pm-9pm.

  • Yi Fang’s solution to Tomoki’s question: “how to replace the second vowel?”

    x <- c("apple", "pear", "banana")
    y <- x %>%
    str_extract("([aeiou].*?[aeiou])") %>%
    str_replace(".$", "-")
    str_replace(x, "([aeiou].*?[aeiou])", y)
    

    Alternatively we can use group backreference

    x <- c("apple", "pear", "banana", "nut")
    str_replace(x, "([aeiou])(.*?)([aeiou])", "\\1\\2-")
    

Today

  • Web scraping

  • HW2