Session Ready
Exercise

Create a list-column data.frame

Let's end our chapter with an implementation of our links extractor, but using a list-column. The idea when using a nested dataframe (i.e., dataframe with a list column) is to keep everything inside a dataframe so that the workflow stays tidy.

You have been provided a tibble called df, which has a column urls with the four URLs you've been using since the beginning of this chapter. If you want to have a look at this dataframe, feel free to print it in the console.

We are going to create a new column called links, which contains the results of the get_links() function (available in your workspace). As the outputs of this function have different lengths, the output will be a list column that you will then need to unnest() to get back a standard dataframe.

Instructions
100 XP
  • Load the three necessary packages: dplyr, tidyr, and purrr

  • Take the df element, and run mutate() on it. mutate() will map the get_links() function on the urls column.

  • Print the result.

  • Unnest the result.