Created
March 4, 2012 11:43
-
-
Save mages/1972617 to your computer and use it in GitHub Desktop.
Number years cities are hosting a CRAN mirror
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
## Copyright Markus Gesmann, March 2011 | |
## Distributed under GPL 2 or later | |
## Since version R-2.0.1 the doc directory includes a list of CRAN mirrors | |
library(googleVis) | |
library(XML) | |
r.tags <- readLines("http://svn.r-project.org/R/tags/") | |
r.tags <- r.tags[grep("R-2-",r.tags)] | |
r.versions <- sapply( strsplit(r.tags, "[< >]", perl=TRUE), '[', 8) | |
r.sources <- sub("/", ".tar.gz", sub("_", "-", gsub("-", ".", sub("-", "_", r.versions)))) | |
r.svn.history <- data.frame(r.versions, r.sources) | |
y=readHTMLTable(readLines("http://cran.r-project.org/src/base/R-2/"), which=1) | |
R.2_history <- merge(r.svn.history, y, by.x="r.sources", by.y="Name") | |
R.2_history$Year <- format(as.POSIXct(as.character( | |
R.2_history[,"Last modified"]), | |
format="%d-%b-%Y %H:%M"), | |
"%Y") | |
cran.mirror.history <- | |
sapply(r.versions[-1], function(i){ | |
cran.file <- | |
paste("http://svn.r-project.org/R/tags/",i,"doc/CRAN_mirrors.csv", | |
sep="") | |
read.csv(cran.file) | |
} | |
) | |
cran.cities.by.R.version <- sapply(sapply(cran.mirror.history, "[[", "City"), unique) | |
cran.cities.by.R.version <- do.call("rbind", | |
lapply(names(cran.cities.by.R.version), function(x) | |
data.frame(Version=x, | |
City=cran.cities.by.R.version[[x]]))) | |
cran.cities.by.R.version <- merge(R.2_history[c("r.versions", "Year")], | |
cran.cities.by.R.version, | |
by.x="r.versions", by.y="Version") | |
cran.cities.years <- | |
as.data.frame(apply(table(unique( | |
cran.cities.by.R.version[c("Year", "City")] | |
)), | |
2, sum)) | |
cran.cities.years$City <- rownames(cran.cities.years) | |
names(cran.cities.years) <- c("Years.hosting.CRAN.mirror", "City") | |
Chart.Cran.Cities <- gvisGeoChart(cran.cities.years, "City", | |
"Years.hosting.CRAN.mirror", | |
options=list( displayMode="markers", | |
markerOpacity=0.5, | |
sizeAxis="{minValue: 0, maxSize: 15}"), | |
chartid="CRAN_Mirror_Cities") | |
plot(Chart.Cran.Cities) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment