8.4 Exercise 1: Scraping tables

  1. For your project you need some data on Swiss cantons namely what their capital is, the population etc. Lucky you.. Wikipedia actually has the data you need on the website: https://en.wikipedia.org/wiki/Cantons_of_Switzerland. Scrape the table that contains the cantons and various statistics about them.
  2. Rename the Population column “population” and the Area column “area”. (Tip: ?dplyr::rename)
  3. You notice that the data in those columns is not numeric (Q: How do we check for that?). Also there seem to be commas in those columns. Get rid of those commas and convert those columns into numeric format. (Tip: ?gsub)
  4. Finally, we would like to know whether population correlates with area. How could we test that? What would you expect?