Learn R Programming

rvest (version 0.2.0)

html_table: Parse an html table into a data frame.

Description

Parse an html table into a data frame.

Usage

html_table(x, header = NA, trim = TRUE, fill = FALSE, dec = ".")

Arguments

Assumptions

html_table currently makes a few assumptions:

  • No cells span multiple rows
  • Headers are in the first row

Examples

Run this code
tdist <- html("http://en.wikipedia.org/wiki/Student%27s_t-distribution")
tdist %>%
  html_node("table.infobox") %>%
  html_table(header = FALSE)

births <- html("http://www.ssa.gov/oact/babynames/numberUSbirths.html")
html_table(html_nodes(births, "table")[[2]])

# If the table is badly formed, and has different number of rows in
# each column use fill = TRUE. Here's it's due to incorrect colspan
# specification.
skiing <- html("http://data.fis-ski.com/dynamic/results.html?sector=CC&raceid=22395")
skiing %>%
  html_table(fill = TRUE)

Run the code above in your browser using DataLab