Charting SVN commits with R

March 22, 2010

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

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


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)




  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. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.