Scraping a HTML table into an R dataframe

For some work I plan on doing for the LACE tech focus blog I wanted to get some information off a webpage and in to an R dataframe. It turns out this is a three line solution (1 line if you throw your URL straight to the function paramaters and have the XML package already installed).

library(XML)
theurl <- "<URL STRING>"
data_frame_of_table <- readHTMLTable(theurl,which=<table number>,as.data.frame = TRUE

I’m pretty sure this is something I will need later in life.. thought I better blog it somewhere..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.