#!/usr/bin/Rscript
###########################################
# author-by-year.r
# Lattice multivariate data visualization
# 2010, Mike Schilli <m@perlmeister.com>
###########################################
library("lattice")

commits <- read.csv("perl-git-log.csv")

commits$year <- format(
  as.POSIXlt(
    commits$time, 
    origin="1970-01-01"), 
  "%Y"
)
  # Authors with more than 5000 
  # file commits
au=table(commits$author)
au = sort(subset( au, au > 5000 ))

files.by.auth.year = 
      table( commits$author, commits$year )
files.by.auth.year = 
      as.data.frame( files.by.auth.year )
names( files.by.auth.year ) = 
      c("author", "year", "files")

files.by.auth.year = subset( 
  files.by.auth.year,
  files.by.auth.year$author %in% names(au)
)

png(file="authors-by-year.png")
xyplot( files ~ year | author, 
    data = files.by.auth.year, 
    layout = c(1, 5), 
    scales = list(x = list(rot = 45)), 
    type = "l",
    xlab = "Year",
    ylab = "File Commits",
    title = "Authors with > 5000 Commits"
)
