Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added an R script sample.

  • Loading branch information...
commit 70d1649b45c676fef82e151856b1df7e9264022a 1 parent de706a2
@ibnfirnas ibnfirnas authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 samples/R/git-punchcard.script!
View
31 samples/R/git-punchcard.script!
@@ -0,0 +1,31 @@
+#! /usr/bin/env Rscript
+# vim: filetype=r:
+
+ParseDates <- function(lines) {
+ dates <- matrix(unlist(strsplit(lines, " +")), ncol=6, byrow=TRUE)
+ days <- dates[,1]
+ times <- dates[,4]
+ hours <- matrix(unlist(strsplit(times, ":")), ncol=3, byrow=TRUE)[,1]
+ all.days <- c("Sun", "Sat", "Fri", "Thu", "Wed", "Tue", "Mon")
+ all.hours <- 0:23
+ data.frame( Day = factor(days , levels=all.days)
+ , Hour = factor(hours, levels=all.hours)
+ )
+}
+
+Main <- function() {
+ lines <- system("git log --format=%ad", intern=TRUE)
+ punchcard <- as.data.frame(table(ParseDates(lines)))
+ punchcard <-
+ ( ggplot2::ggplot(punchcard, ggplot2::aes(y=Day, x=Hour))
+ + ggplot2::geom_point(ggplot2::aes(size=Freq))
+ + ggplot2::scale_size(range=c(0, 15))
+ )
+ ggplot2::ggsave( filename = "punchcard.png"
+ , plot = punchcard
+ , width = 10
+ , height = 5
+ )
+}
+
+Main()
Please sign in to comment.
Something went wrong with that request. Please try again.