Created
November 23, 2011 17:29
-
-
Save simecek/1389293 to your computer and use it in GitHub Desktop.
Prague Half Marathon 2010
This file contains 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
library(xlsReadWrite) | |
library(MASS) | |
### DATA DOWNLOAD | |
dir.name <- tempdir() | |
url2010 <- "http://www.praguemarathon.com/images/stories/articles/files/HM2010/HM2010_eng.xls" | |
file <- paste(dir.name, "2010.xls", sep="\\") | |
download.file(url2010, file, mode="wb") | |
data2010 <- read.xls(file) | |
names(data2010)[1] <- "number" | |
data2010 <- data2010[-2471,] #Realtime = 0:00:00 | |
url2009 <- "http://behycz.s3.amazonaws.com/media/files/vysledky/2113-hervis-1-2maraton-praha.xls?1299838523" | |
file <- paste(dir.name, "2009.xls", sep="\\") | |
download.file(url2009, file, mode="wb") | |
data2009 <- read.xls(file) | |
names(data2009) <- names(data2010) | |
url2011 <- "http://behejcom.s3.amazonaws.com/media/files/other/neoficialni%20vysledky%20Hervis%20pulmaratonu%202011.xls?1301767966" | |
file <- paste(dir.name, "2011.xls", sep="\\") | |
download.file(url2011, file, mode="wb") | |
data2011 <- read.xls(file) | |
names(data2011)[1:16] <- names(data2010)[1:16] | |
### START TIME COMPUTATION | |
data2010$start.time <- strptime(data2010$Offic..time,"%H:%M:%S") - strptime(data2010$Real.time,"%H:%M:%S") | |
data2010$start.time <- as.numeric(data2010$start.time) | |
data2009$start.time <- strptime(data2009$Offic..time,"%H:%M:%S") - strptime(data2009$Real.time,"%H:%M:%S") | |
data2009$start.time <- as.numeric(data2009$start.time) | |
data2011$start.time <- strptime(data2011$Offic..time,"%H:%M:%S") - strptime(data2011$Real.time,"%H:%M:%S") | |
data2011$start.time <- as.numeric(data2011$start.time) | |
### HISTOGRAMS | |
with(data2009, hist(start.time,breaks=seq(from=-10,to=max(start.time),by=1), main="Histogram of start times in 2009", xlim=c(0,570), ylim=c(0,250), xlab="Start time [s]")) | |
abline(h=20, col="red", lty=2) | |
with(data2010, hist(start.time,breaks=seq(from=0,to=max(start.time),by=1), main="Histogram of start times in 2010", xlim=c(0,570), ylim=c(0,250), xlab="Start time [s]")) | |
abline(h=20, col="red", lty=2) | |
with(data2011, hist(start.time,breaks=seq(from=0,to=max(start.time),by=1), main="Histogram of start times in 2011", xlim=c(0,570), ylim=c(0,250), xlab="Start time [s]")) | |
abline(h=20, col="red", lty=2) | |
### ORDERING TO CORRIDORS | |
with(subset(data2009, Sex=="M"& as.numeric(number)<3000), plot(start.time ~ as.numeric(number), cex=0.1, main="Ordering to corridors in 2009", ylim=c(0,600), xlab="Start number", ylab="Start time [s]")) | |
with(subset(data2010, Sex=="M" & as.numeric(number)<3000), plot(start.time ~ as.numeric(number), cex=0.1, main="Ordering to corridors in 2010", ylim=c(0,600), xlab="Start number", ylab="Start time [s]")) | |
with(subset(data2011, Sex=="M"& as.numeric(number)<3000), plot(start.time ~ as.numeric(number), cex=0.1, main="Ordering to corridors in 2011", ylim=c(0,600), xlab="Start number", ylab="Start time [s]")) | |
abline(rlm(start.time ~ as.numeric(number), data=subset(data2011, Sex=="M"& as.numeric(number)<3000)), col="blue", lty=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment