Exercise

Parse hyperlinks into a data frame

Have a look at the following ul list of "helpful links".

It consists of three li elements that in turn contain a elements with the links:


Helpful links

  • Wikipedia
  • Dictionary
  • Search Engine

Compiled with help from Google.


The corresponding HTML code is available as a string in hyperlink_raw_html.

In this exercise, you'll parse these links into an R data frame by selecting only a elements that are within li elements.

PS: You'll use tibble(), a function from the Tidyverse, for that. tibble() is basically a trimmed down version of data.frame(), which you certainly already know. Just like data.frame(), you specify column names and data as pairs of column names and values, like so:

my_tibble <- tibble(
  column_name_1 = value_1,
  column_name_2 = value_2,
  ...
)

Instructions 1/2

undefined XP
    1
    2
  • Extract all the a nodes that are within the bulleted list, using html_elements().