Created
November 11, 2010 16:30
-
-
Save johnjosephhorton/672733 to your computer and use it in GitHub Desktop.
How to parse HTML tables using R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: http://learnr.wordpress.com/2010/01/21/ggplot2-crayola-crayon-colours/ | |
library(XML) | |
library(ggplot2) | |
theurl <- "http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors" | |
html <- htmlParse(theurl) | |
sched <- readHTMLTable(html, stringsAsFactors = FALSE) | |
crayola <- readHTMLTable(html, stringsAsFactors = FALSE)[[2]] | |
crayola <- crayola[, c("Hex Code", "Issued", "Retired")] | |
names(crayola) <- c("colour", "issued", "retired") | |
crayola <- crayola[!duplicated(crayola$colour),] | |
crayola$retired[crayola$retired == ""] <- 2010 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got this from: http://learnr.wordpress.com/2010/01/21/ggplot2-crayola-crayon-colours/
Sticking it here b/c I find myself referring to it frequently.