Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Created October 5, 2012 15:06
Show Gist options
  • Save vgaltes/3840364 to your computer and use it in GitHub Desktop.
Save vgaltes/3840364 to your computer and use it in GitHub Desktop.
Prova Gist
# load url and packages
url <- "http://www2.idrottonline.se/UppsalaLK/KungBjorn-loppet/KungBjorn-loppet2012/Resultat2012/"
require(plyr)
require(XML)
require(RCurl)
# get & format the data
doc <- getURL(url)
doc2 <- htmlTreeParse(doc, asText = TRUE, useInternalNodes = TRUE)
tables <- getNodeSet(doc2, "//table")
t <- readHTMLTable(tables[[1]])
tt <- as.matrix(t)
tt <- as.data.frame(tt)
# Select only the 10K men class and make variable names
data <- tt[c(150:391), c(2, 3, 4, 6)]
colnames(data) <- c("place", "number", "name", "time")
head(data)
## place number name time
## 150 1 624 Hedlöf Viktor 32:52
## 151 2 631 Vikner Joel 33:18
## 152 3 414 Sjögren Niclas 33:47
## 153 4 329 Swahn Fredrik 33:48
## 154 5 278 Sjöblom Albin 34:04
## 155 6 311 Lindgren Fredrik 35:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment