Session Ready
Exercise

Turn a table into a data frame with html_table()

If a table has a header row (with th elements) and no gaps, scraping it is straightforward, as with the following table (having ID "clean"):

Mountain Height First ascent Country
Mount Everest 8848 1953 Nepal, China
...

Here's the same table (having ID "dirty") without a designated header row and a missing cell in the first row:

Mountain Height First ascent Country
Mount Everest 8848 1953
...

For such cases, html_table() has a couple of extra arguments you can use to correctly parse the table, as shown in the video.

Both tables are contained within the mountains_html document.

Instructions 1/2
undefined XP
  • 1

    Turn the table with ID "clean" into a data frame called mountains.

    • 2
      • Do the same with the "dirty" table, but treat the first line as header and fill up missing cells.