Charting SVN commits with R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Want to get a quick sense of who are the most active committers to your SVN project? Using just a few lines of R code and the SVN log file, reader and new R user Rhys Kidd created this chart to review commits to the Freespace 2 Source Code Project

Freespace_commits

Rhys posts the 6 lines of R code to create the plot in this forum post, and I recreate it here (with some slight reformatting):

system(“svn log > fs2_open.svnlog”)

x <- readLines("fs2_open.svnlog")

rx <- x[grep("^r[0-9]{1,5} \\|",x)]

who <- gsub(" ","",sapply(strsplit(rx,"\\|"),"[",2))

ctab <- table(who)

dotplot(ctab[order(ctab)],

  scales=list(x=list()),

  xlab=””,

  main=”Number of fs2_open SVN commits Jan 2007 to Mar 2010″)

Note the use of the system command to dynamically create the SVN log — each time the R code is run, an up-to-date analysis of the commit rates is made. Regular expressions extract the commits and user names from the log file, which are then tabulated for display with the dotplot command. That’s some pretty tight code for (in RK’s words) a “new-ish R user” — although he says he did get inspirations from Dirk Eddelbuettel’s recent talk at the University of Chicago. (Update: Dirk points out that Ben Bolker originated the idea at UseR 2007. It’s a great example of how reading from connections — here, a log file — makes for compact, powerful code.)

Incidentally, I was amused by the first response on the forum: “Independent variable…on vertical axis…*twitch*”. Actually, a dot chart is a great choice for data like this: the sorting gives a convenient read of the most and least prolific committers; it’s easy for the eye to make numerical comparison between rows, and the use of dots instead of the “natural” bars makes for a clean, easy-to-read chart.

The FreeSpace Source Code Project forum: Charting the development of the fs2_open codebase

To leave a comment for the author, please follow the link and comment on their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)