Created
October 9, 2011 22:00
-
-
Save mages/1274265 to your computer and use it in GitHub Desktop.
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
bibfile <- readLines("http://www.r-project.org/doc/bib/R-books.bib") | |
pub.start.pos <- regexpr("publisher =", bibfile, perl=TRUE) | |
pub.lines <- which( pub.start.pos > 0 ) | |
pub.split <- strsplit(bib[pub.lines], "[ =,]", perl=TRUE) | |
publishers <- sapply(pub.split, function(x) paste(x[-c(1:5)])) | |
publishers <- gsub("[{}\"),\\]", "", publishers) | |
publishers <- gsub("c\\(", "", publishers) | |
s=c("Springer", "Wiley", "Sage", "Chapman & Hall", "CRC press", "Servicio") | |
r=c("Springer", "Wiley", "Sage", "Chapman & Hall/CRC", | |
"Chapman & Hall/CRC","Universidad de La Rioja") | |
for(i in seq(along=s)){ | |
publishers[regexpr(s[i], publishers, ignore.case=TRUE) > 0] <- r[i] | |
} | |
pubs <- table(publishers) | |
pubs <- pubs[order(pubs)] | |
opar <- par(mar = c(4, 15, 4, 2)) | |
barplot(pubs, horiz=TRUE, las=1, | |
xlab=format(Sys.time(), "As at %d %b %Y"), | |
border=NA, main="Number of R books\nby publisher") | |
par(opar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment