setwd("/Users/msonnabaum")
require(ggplot2)
require(gridExtra)
require(plyr)
require(lubridate)
require(scales)

df <- read.csv("wmg_37_46.csv")
datetime <- paste(df$Date, df$Time)
df$datetime <- mdy_hms(datetime)
df <- df[!is.na(df$datetime), ]
df$Success <- as.factor(df$Success)

p1 <- ggplot(df, aes(datetime, Total.Time, fill = alpha("red", 0.7), group = round_any(datetime, 
    43200, floor))) + geom_boxplot(outlier.colour = alpha("red", 0.3)) + scale_x_datetime(breaks = date_breaks("1 day"), 
    labels = date_format("%m/%d")) + theme_bw() + coord_cartesian(c(as.POSIXct("2013-03-07 00:00:00 UTC"), 
    max(df$datetime))) + labs(title = "Response times")

p2 <- ggplot(df[df$Error.Type == "TIMEOUT", ], aes(datetime, fill = Error.Type)) + 
    geom_bar(binwidth = 43200) + scale_x_datetime(breaks = date_breaks("1 day"), 
    labels = date_format("%m/%d")) + theme_bw() + coord_cartesian(c(as.POSIXct("2013-03-07 00:00:00 UTC"), 
    max(df$datetime))) + labs(title = "Number of timeouts")

gp1 <- ggplot_gtable(ggplot_build(p1))
gp2 <- ggplot_gtable(ggplot_build(p2))
maxWidth = unit.pmax(gp1$widths[2:3], gp2$widths[2:3])
gp1$widths[2:3] <- maxWidth
gp2$widths[2:3] <- maxWidth
grid.arrange(gp2, gp1)

plot of chunk unnamed-chunk-1