Skip to content

Instantly share code, notes, and snippets.

@mages
Created October 9, 2011 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mages/1274265 to your computer and use it in GitHub Desktop.
Save mages/1274265 to your computer and use it in GitHub Desktop.
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