[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [ernie/master] Don't break in plot.sh if we're missing input files.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Thu, 20 May 2010 11:50:30 +0200
Subject: Don't break in plot.sh if we're missing input files.
Commit: 47f49567f1a1cb032b0744c85fd200a94f78fd5b

---
 R/bridge-stats.R     |   15 ++--
 R/consensus-stats.R  |   65 ++++++++++-------
 R/descriptor-stats.R |   39 ++++++----
 R/dirreq-stats.R     |   46 ++++++------
 R/gettor.R           |   76 ++++++++++----------
 R/monthly-users.R    |  103 ++++++++++++++-------------
 R/torperf.R          |  192 +++++++++++++++++++++++++-------------------------
 7 files changed, 282 insertions(+), 254 deletions(-)

diff --git a/R/bridge-stats.R b/R/bridge-stats.R
index 066e51f..c353522 100644
--- a/R/bridge-stats.R
+++ b/R/bridge-stats.R
@@ -1,12 +1,6 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-bridge <- read.csv("stats/bridge-stats", header = TRUE,
-  stringsAsFactors = FALSE)
-bridge <- bridge[1:length(bridge$date)-1,]
-write.csv(bridge, "website/csv/bridge-users.csv", quote = FALSE,
-  row.names = FALSE)
-
 plot_bridges <- function(filename, title, limits, code) {
   c <- data.frame(date = bridge$date, users = bridge[[code]])
   ggplot(c, aes(x = as.Date(date, "%Y-%m-%d"), y = users)) +
@@ -136,5 +130,12 @@ countries <- data.frame(code = c("bh", "cn", "cu", "et", "ir", "mm", "sa",
   "syria", "tunisia", "turkmenistan", "uzbekistan", "vietnam", "yemen"),
   stringsAsFactors = FALSE)
 
-plot_current(countries)
+if (file.exists("stats/bridge-stats")) {
+  bridge <- read.csv("stats/bridge-stats", header = TRUE,
+    stringsAsFactors = FALSE)
+  bridge <- bridge[1:length(bridge$date)-1,]
+  write.csv(bridge, "website/csv/bridge-users.csv", quote = FALSE,
+    row.names = FALSE)
+  plot_current(countries)
+}
 
diff --git a/R/consensus-stats.R b/R/consensus-stats.R
index 6dec8ed..ba6763d 100644
--- a/R/consensus-stats.R
+++ b/R/consensus-stats.R
@@ -1,30 +1,37 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-relaysDay <- read.csv("stats/consensus-stats-raw", stringsAsFactors = FALSE)
-to <- Sys.time()
-from <- seq(from = to, length = 2, by = "-3 days")[2]
-relaysDay <- subset(relaysDay, as.POSIXct(datetime, tz = "GMT") >= from)
-m <- melt(relaysDay[,c(1, 5, 2)], id = "datetime")
-ggplot(m, aes(x = as.POSIXct(datetime, tz = "GMT"), y = value,
-  colour = variable)) + geom_point() +
-  scale_x_datetime(name = "", limits = c(from, to)) +
-  scale_y_continuous(name = "") +
-  scale_colour_hue("", breaks = c("running", "exit"),
-  labels = c("All relays", "Exit relays")) +
-  opts(title = "Number of exit relays (past 72 hours)\n")
-ggsave(filename = "website/graphs/exit/exit-72h.png",
-  width = 8, height = 5, dpi = 72)
+if (file.exists("stats/consensus-stats-raw")) {
+  relaysDay <- read.csv("stats/consensus-stats-raw",
+    stringsAsFactors = FALSE)
+  to <- Sys.time()
+  from <- seq(from = to, length = 2, by = "-3 days")[2]
+  relaysDay <- subset(relaysDay, as.POSIXct(datetime, tz = "GMT") >= from)
+  if (length(relaysDay$datetime) > 0) {
+    m <- melt(relaysDay[,c(1, 5, 2)], id = "datetime")
+    ggplot(m, aes(x = as.POSIXct(datetime, tz = "GMT"), y = value,
+      colour = variable)) + geom_point() +
+      scale_x_datetime(name = "", limits = c(from, to)) +
+      scale_y_continuous(name = "") +
+      scale_colour_hue("", breaks = c("running", "exit"),
+      labels = c("All relays", "Exit relays")) +
+      opts(title = "Number of exit relays (past 72 hours)\n")
+    ggsave(filename = "website/graphs/exit/exit-72h.png",
+      width = 8, height = 5, dpi = 72)
+  }
+}
 
-consensuses <- read.csv("stats/consensus-stats", header = TRUE,
-    stringsAsFactors = FALSE);
-consensuses <- consensuses[1:length(consensuses$date)-1,]
-write.csv(data.frame(date = consensuses$date,
-  relays = consensuses$running, bridges = consensuses$brunning),
-  "website/csv/networksize.csv", quote = FALSE, row.names = FALSE)
-write.csv(data.frame(date = consensuses$date,
-  all = consensuses$running, exit = consensuses$exit),
-  "website/csv/exit.csv", quote = FALSE, row.names = FALSE)
+if (file.exists("stats/consensus-stats")) {
+  consensuses <- read.csv("stats/consensus-stats", header = TRUE,
+      stringsAsFactors = FALSE);
+  consensuses <- consensuses[1:length(consensuses$date)-1,]
+  write.csv(data.frame(date = consensuses$date,
+    relays = consensuses$running, bridges = consensuses$brunning),
+    "website/csv/networksize.csv", quote = FALSE, row.names = FALSE)
+  write.csv(data.frame(date = consensuses$date,
+    all = consensuses$running, exit = consensuses$exit),
+    "website/csv/exit.csv", quote = FALSE, row.names = FALSE)
+}
 
 plot_consensus <- function(directory, filename, title, limits, rows, breaks,
     labels) {
@@ -139,9 +146,11 @@ plot_current <- function(directory, filenamePart, titlePart, rows, breaks,
   plot_all(directory, filenamePart, titlePart, rows, breaks, labels)
 }
 
-plot_current("website/graphs/networksize/", "networksize",
-  "Number of relays and bridges", c(1, 5, 7),
-  c("running", "brunning"), c("Relays", "Bridges"))
-plot_current("website/graphs/exit/", "exit", "Number of exit relays",
-  c(1, 5, 2), c("running", "exit"), c("All relays", "Exit relays"))
+if (file.exists("stats/consensus-stats")) {
+  plot_current("website/graphs/networksize/", "networksize",
+    "Number of relays and bridges", c(1, 5, 7),
+    c("running", "brunning"), c("Relays", "Bridges"))
+  plot_current("website/graphs/exit/", "exit", "Number of exit relays",
+    c(1, 5, 2), c("running", "exit"), c("All relays", "Exit relays"))
+}
 
diff --git a/R/descriptor-stats.R b/R/descriptor-stats.R
index 1ff5f47..9cb25a8 100644
--- a/R/descriptor-stats.R
+++ b/R/descriptor-stats.R
@@ -1,19 +1,6 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-versions <- read.csv("stats/version-stats", header = TRUE,
-    colClasses = c(date = "Date"))
-platforms <- read.csv("stats/platform-stats", header = TRUE,
-    colClasses = c(date = "Date"))
-bandwidth <- read.csv("stats/bandwidth-stats", header = TRUE,
-    colClasses = c(date = "Date"))
-write.csv(versions, "website/csv/versions.csv", quote = FALSE,
-  row.names = FALSE)
-write.csv(platforms, "website/csv/platforms.csv", quote = FALSE,
-  row.names = FALSE)
-write.csv(bandwidth, "website/csv/bandwidth.csv", quote = FALSE,
-  row.names = FALSE)
-
 plot_versions <- function() {
   v <- melt(versions, id = "date")
   ggplot(v, aes(x = date, y = value, colour = variable)) +
@@ -54,7 +41,27 @@ plot_bandwidth <- function() {
     width = 8, height = 5, dpi = 72)
 }
 
-plot_versions()
-plot_platforms()
-plot_bandwidth()
+if (file.exists("stats/version-stats")) {
+  versions <- read.csv("stats/version-stats", header = TRUE,
+      colClasses = c(date = "Date"))
+  write.csv(versions, "website/csv/versions.csv", quote = FALSE,
+    row.names = FALSE)
+  plot_versions()
+}
+
+if (file.exists("stats/platform-stats")) {
+  platforms <- read.csv("stats/platform-stats", header = TRUE,
+      colClasses = c(date = "Date"))
+  write.csv(platforms, "website/csv/platforms.csv", quote = FALSE,
+    row.names = FALSE)
+  plot_platforms()
+}
+
+if (file.exists("stats/bandwidth-stats")) {
+  bandwidth <- read.csv("stats/bandwidth-stats", header = TRUE,
+      colClasses = c(date = "Date"))
+  write.csv(bandwidth, "website/csv/bandwidth.csv", quote = FALSE,
+    row.names = FALSE)
+  plot_bandwidth()
+}
 
diff --git a/R/dirreq-stats.R b/R/dirreq-stats.R
index 0a48b6f..b44dadb 100644
--- a/R/dirreq-stats.R
+++ b/R/dirreq-stats.R
@@ -1,24 +1,6 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-dirreq <- read.csv("stats/dirreq-stats", header = TRUE,
-  stringsAsFactors = FALSE)
-gabelmooSub <- subset(dirreq, directory %in%
-  c("68333D0761BCF397A587A0C0B963E4A9E99EC4D3",
-    "F2044413DAC2E02E3D6BCF4735A19BCA1DE97281"))
-gabelmoo <- data.frame(date = gabelmooSub$date,
-  gabelmooSub[3:(length(gabelmooSub) - 1)] * 6)
-trustedSub <- subset(dirreq,
-  directory %in% "8522EB98C91496E80EC238E732594D1509158E77")
-trustedSub[na.omit(trustedSub$share) == 0,3:length(trustedSub)] <- NA
-trusted <- data.frame(date = trustedSub$date,
-  floor(trustedSub[3:(length(trustedSub) - 1)] / trustedSub$share * 10))
-
-write.csv(gabelmoo, "website/csv/new-users.csv", quote = FALSE,
-  row.names = FALSE)
-write.csv(trusted, "website/csv/recurring-users.csv", quote = FALSE,
-  row.names = FALSE)
-
 plot_dirreq <- function(directory, filename, title, limits, data, code) {
   c <- data.frame(date = data$date, users = data[[code]])
   ggplot(c, aes(x = as.Date(date, "%Y-%m-%d"), y = users)) +
@@ -162,8 +144,28 @@ countries <- data.frame(code = c("bh", "cn", "cu", "et", "ir", "mm", "sa",
   "syria", "tunisia", "turkmenistan", "uzbekistan", "vietnam", "yemen"),
   stringsAsFactors = FALSE)
 
-plot_current("website/graphs/new-users/", "-new",
-  "New or returning, directly connecting", gabelmoo, countries)
-plot_current("website/graphs/direct-users/", "-direct",
-  "Recurring, directly connecting", trusted, countries)
+if (file.exists("stats/dirreq-stats")) {
+  dirreq <- read.csv("stats/dirreq-stats", header = TRUE,
+    stringsAsFactors = FALSE)
+  gabelmooSub <- subset(dirreq, directory %in%
+    c("68333D0761BCF397A587A0C0B963E4A9E99EC4D3",
+      "F2044413DAC2E02E3D6BCF4735A19BCA1DE97281"))
+  gabelmoo <- data.frame(date = gabelmooSub$date,
+    gabelmooSub[3:(length(gabelmooSub) - 1)] * 6)
+  trustedSub <- subset(dirreq,
+    directory %in% "8522EB98C91496E80EC238E732594D1509158E77")
+  trustedSub[na.omit(trustedSub$share) == 0,3:length(trustedSub)] <- NA
+  trusted <- data.frame(date = trustedSub$date,
+    floor(trustedSub[3:(length(trustedSub) - 1)] / trustedSub$share * 10))
+
+  write.csv(gabelmoo, "website/csv/new-users.csv", quote = FALSE,
+    row.names = FALSE)
+  write.csv(trusted, "website/csv/recurring-users.csv", quote = FALSE,
+    row.names = FALSE)
+
+  plot_current("website/graphs/new-users/", "-new",
+    "New or returning, directly connecting", gabelmoo, countries)
+  plot_current("website/graphs/direct-users/", "-direct",
+    "Recurring, directly connecting", trusted, countries)
+}
 
diff --git a/R/gettor.R b/R/gettor.R
index 2273ac3..7470d26 100644
--- a/R/gettor.R
+++ b/R/gettor.R
@@ -1,44 +1,46 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-gettor <- read.csv("stats/gettor-stats", header = TRUE,
-    stringsAsFactors = FALSE);
-start <- as.Date(min(gettor$date))
-end <- seq(from = Sys.Date(), length = 2, by = "-1 day")[2]
-total <- data.frame(date = gettor$date,
-  packages = rowSums(gettor[2:length(gettor)]) - gettor$none)
-en <- data.frame(date = gettor$date,
-  packages = gettor$tor.browser.bundle_en + gettor$tor.im.browser.bundle_en)
-zh_cn <- data.frame(date = gettor$date,
-  packages = gettor$tor.browser.bundle_zh_cn +
-  gettor$tor.im.browser.bundle_zh_cn)
-fa <- data.frame(date = gettor$date,
-  packages = gettor$tor.browser.bundle_fa + gettor$tor.im.browser.bundle_fa)
+if (file.exists("stats/gettor-stats")) {
+  gettor <- read.csv("stats/gettor-stats", header = TRUE,
+      stringsAsFactors = FALSE);
+  start <- as.Date(min(gettor$date))
+  end <- seq(from = Sys.Date(), length = 2, by = "-1 day")[2]
+  total <- data.frame(date = gettor$date,
+    packages = rowSums(gettor[2:length(gettor)]) - gettor$none)
+  en <- data.frame(date = gettor$date,
+    packages = gettor$tor.browser.bundle_en + gettor$tor.im.browser.bundle_en)
+  zh_cn <- data.frame(date = gettor$date,
+    packages = gettor$tor.browser.bundle_zh_cn +
+    gettor$tor.im.browser.bundle_zh_cn)
+  fa <- data.frame(date = gettor$date,
+    packages = gettor$tor.browser.bundle_fa + gettor$tor.im.browser.bundle_fa)
 
-write.csv(data.frame(date = gettor$date,
-  total = rowSums(gettor[2:length(gettor)]) - gettor$none,
-  en = gettor$tor.browser.bundle_en + gettor$tor.im.browser.bundle_en,
-  zh_cn = gettor$tor.browser.bundle_zh_cn +
-    gettor$tor.im.browser.bundle_zh_cn,
-  fa = gettor$tor.browser.bundle_fa + gettor$tor.im.browser.bundle_fa),
-  "website/csv/gettor.csv", quote = FALSE, row.names = FALSE)
+  write.csv(data.frame(date = gettor$date,
+    total = rowSums(gettor[2:length(gettor)]) - gettor$none,
+    en = gettor$tor.browser.bundle_en + gettor$tor.im.browser.bundle_en,
+    zh_cn = gettor$tor.browser.bundle_zh_cn +
+      gettor$tor.im.browser.bundle_zh_cn,
+    fa = gettor$tor.browser.bundle_fa + gettor$tor.im.browser.bundle_fa),
+    "website/csv/gettor.csv", quote = FALSE, row.names = FALSE)
 
-plot_packages <- function(filename, title, data) {
-  ggplot(data, aes(x = as.Date(date, "%Y-%m-%d"), y = packages)) + geom_line() +
-    scale_x_date(name = "", limits = c(start, end)) +
-    scale_y_continuous(name = "",
-    limits = c(0, max(data$packages, na.rm = TRUE))) +
-    opts(title = paste(title, "\n", sep = ""))
-  ggsave(filename = paste("website/graphs/gettor/", filename, sep = ""),
-    width = 8, height = 5, dpi = 72)
-}
+  plot_packages <- function(filename, title, data) {
+    ggplot(data, aes(x = as.Date(date, "%Y-%m-%d"), y = packages)) + geom_line() +
+      scale_x_date(name = "", limits = c(start, end)) +
+      scale_y_continuous(name = "",
+      limits = c(0, max(data$packages, na.rm = TRUE))) +
+      opts(title = paste(title, "\n", sep = ""))
+    ggsave(filename = paste("website/graphs/gettor/", filename, sep = ""),
+      width = 8, height = 5, dpi = 72)
+  }
 
-plot_packages("gettor-total.png",
-  "Total packages requested from GetTor per day", total)
-plot_packages("gettor-en.png",
-  "Tor Browser Bundles (en) requested from GetTor per day", en)
-plot_packages("gettor-zh_cn.png",
-  "Tor Browser Bundles (zh_CN) requested from GetTor per day", zh_cn)
-plot_packages("gettor-fa.png",
-  "Tor Browser Bundles (fa) requested from GetTor per day", fa)
+  plot_packages("gettor-total.png",
+    "Total packages requested from GetTor per day", total)
+  plot_packages("gettor-en.png",
+    "Tor Browser Bundles (en) requested from GetTor per day", en)
+  plot_packages("gettor-zh_cn.png",
+    "Tor Browser Bundles (zh_CN) requested from GetTor per day", zh_cn)
+  plot_packages("gettor-fa.png",
+    "Tor Browser Bundles (fa) requested from GetTor per day", fa)
+}
 
diff --git a/R/monthly-users.R b/R/monthly-users.R
index 46e6d57..21c0afc 100644
--- a/R/monthly-users.R
+++ b/R/monthly-users.R
@@ -1,53 +1,58 @@
 options(warn = -1)
 suppressPackageStartupMessages(library("ggplot2"))
 
-# Read direct user numbers
-dirreq <- read.csv("stats/dirreq-stats", header = TRUE,
-  stringsAsFactors = FALSE)
-trustedSub <- subset(dirreq,
-  directory %in% "8522EB98C91496E80EC238E732594D1509158E77")
-trustedSub[na.omit(trustedSub$share) == 0,3:length(trustedSub)] <- NA
-trusted <- data.frame(date = trustedSub$date,
-  floor(trustedSub[3:(length(trustedSub) - 1)] / trustedSub$share * 10))
-
-# Read bridge user numbers
-bridge <- read.csv("stats/bridge-stats", header = TRUE,
-  stringsAsFactors = FALSE)
-bridge <- bridge[1:length(bridge$date)-1,]
-bridge <- data.frame(date = bridge[,1],
-  floor(bridge[,2:length(bridge[1,])]))
-
-# Melt both data frames and append them
-bridge_melted <- data.frame(melt(bridge, id.vars = "date", na.rm = TRUE),
-  source = "bridge")
-direct_melted <- data.frame(melt(trusted, id.vars = "date", na.rm = TRUE),
-  source = "direct")
-both_melted <- rbind(bridge_melted, direct_melted)
-
-# Merge data source (bridge or direct)
-country_day <- aggregate(both_melted$value,
-  by = list(date = both_melted$date, country = both_melted$variable), sum)
-
-# Merge months
-month_mean <- aggregate(country_day$x,
-  by = list(month = substr(country_day$date, 1, 7),
-  country = country_day$country), mean)
-month_max <- aggregate(country_day$x,
-  by = list(month = substr(country_day$date, 1, 7),
-  country = country_day$country), max)
-
-# Convert to final matrices
-month_peak <- t(matrix(month_max$x,
-  ncol = length(unique(month_max$country)),
-  dimnames = list(unique(month_max$month),
-  as.vector(unique(month_max$country)))))
-month_avg <- t(matrix(floor(month_mean$x),
-  ncol = length(unique(month_mean$country)),
-  dimnames = list(unique(month_mean$month),
-  as.vector(unique(month_mean$country)))))
-
-# Write to disk
-write.csv(month_peak, "website/csv/monthly-users-peak.csv", quote = FALSE)
-write.csv(month_avg, "website/csv/monthly-users-average.csv",
-  quote = FALSE)
+# Ensure that both input files exist
+if (file.exists("stats/dirreq-stats") &
+    file.exists("stats/bridge-stats")) {
+
+  # Read direct user numbers
+  dirreq <- read.csv("stats/dirreq-stats", header = TRUE,
+    stringsAsFactors = FALSE)
+  trustedSub <- subset(dirreq,
+    directory %in% "8522EB98C91496E80EC238E732594D1509158E77")
+  trustedSub[na.omit(trustedSub$share) == 0,3:length(trustedSub)] <- NA
+  trusted <- data.frame(date = trustedSub$date,
+    floor(trustedSub[3:(length(trustedSub) - 1)] / trustedSub$share * 10))
+
+  # Read bridge user numbers
+  bridge <- read.csv("stats/bridge-stats", header = TRUE,
+    stringsAsFactors = FALSE)
+  bridge <- bridge[1:length(bridge$date)-1,]
+  bridge <- data.frame(date = bridge[,1],
+    floor(bridge[,2:length(bridge[1,])]))
+
+  # Melt both data frames and append them
+  bridge_melted <- data.frame(melt(bridge, id.vars = "date", na.rm = TRUE),
+    source = "bridge")
+  direct_melted <- data.frame(melt(trusted, id.vars = "date", na.rm = TRUE),
+    source = "direct")
+  both_melted <- rbind(bridge_melted, direct_melted)
+
+  # Merge data source (bridge or direct)
+  country_day <- aggregate(both_melted$value,
+    by = list(date = both_melted$date, country = both_melted$variable), sum)
+
+  # Merge months
+  month_mean <- aggregate(country_day$x,
+    by = list(month = substr(country_day$date, 1, 7),
+    country = country_day$country), mean)
+  month_max <- aggregate(country_day$x,
+    by = list(month = substr(country_day$date, 1, 7),
+    country = country_day$country), max)
+
+  # Convert to final matrices
+  month_peak <- t(matrix(month_max$x,
+    ncol = length(unique(month_max$country)),
+    dimnames = list(unique(month_max$month),
+    as.vector(unique(month_max$country)))))
+  month_avg <- t(matrix(floor(month_mean$x),
+    ncol = length(unique(month_mean$country)),
+    dimnames = list(unique(month_mean$month),
+    as.vector(unique(month_mean$country)))))
+
+  # Write to disk
+  write.csv(month_peak, "website/csv/monthly-users-peak.csv", quote = FALSE)
+  write.csv(month_avg, "website/csv/monthly-users-average.csv",
+    quote = FALSE)
+}
 
diff --git a/R/torperf.R b/R/torperf.R
index 06eb4fa..b9d32ef 100644
--- a/R/torperf.R
+++ b/R/torperf.R
@@ -1,116 +1,118 @@
 # TODO this file is a hack! find a better solution with ggplot2?
 
-t <- read.csv("stats/torperf-stats")
-write.csv(t, "website/csv/torperf.csv", quote = FALSE, row.names = FALSE)
+if (file.exists("stats/torperf-stats")) {
+  t <- read.csv("stats/torperf-stats")
+  write.csv(t, "website/csv/torperf.csv", quote = FALSE, row.names = FALSE)
 
-intervals <- c("12m", "6m", "2w")
-intervalsStr <- c("-12 months", "-6 months", "-2 weeks")
+  intervals <- c("12m", "6m", "2w")
+  intervalsStr <- c("-12 months", "-6 months", "-2 weeks")
 
-for (intervalInd in 1:length(intervals)) {
-  interval <- intervals[intervalInd]
-  intervalStr <- intervalsStr[intervalInd]
+  for (intervalInd in 1:length(intervals)) {
+    interval <- intervals[intervalInd]
+    intervalStr <- intervalsStr[intervalInd]
 
-  end <- seq(from = Sys.Date(), length = 2, by = "-1 day")[2]
-  start <- seq(seq(from = end, length = 2,
-      by=intervalStr)[2], length=2, by="1 day")[2]
-  dates <- seq(from = start, to = end, by="1 day")
-  datesStr <- as.character(dates)
-  firstdays <- c()
-  for (i in datesStr)
-    if (intervalInd == 3 || format(as.POSIXct(i, tz="GMT"), "%d") == "01")
-      firstdays <- c(firstdays, i)
-  monthticks <- which(datesStr %in% firstdays)
-  monthlabels <- c() 
-  for (i in monthticks[1:(length(monthticks) - 2)])
+    end <- seq(from = Sys.Date(), length = 2, by = "-1 day")[2]
+    start <- seq(seq(from = end, length = 2,
+        by=intervalStr)[2], length=2, by="1 day")[2]
+    dates <- seq(from = start, to = end, by="1 day")
+    datesStr <- as.character(dates)
+    firstdays <- c()
+    for (i in datesStr)
+      if (intervalInd == 3 || format(as.POSIXct(i, tz="GMT"), "%d") == "01")
+        firstdays <- c(firstdays, i)
+    monthticks <- which(datesStr %in% firstdays)
+    monthlabels <- c()
+    for (i in monthticks[1:(length(monthticks) - 2)])
+      monthlabels <- c(monthlabels,
+          format(as.POSIXct(dates[i + 1], tz="GMT"),
+          ifelse(intervalInd == 3, "%b %d", "%b")))
     monthlabels <- c(monthlabels,
-        format(as.POSIXct(dates[i + 1], tz="GMT"),
-        ifelse(intervalInd == 3, "%b %d", "%b")))
-  monthlabels <- c(monthlabels,
-      format(as.POSIXct(dates[monthticks[length(monthticks) - 1] + 1]),
-      ifelse(intervalInd == 3, "%b %d", "%b %y")))
-  if (intervalInd == 3)
-    monthlabels[length(monthlabels)] <- ""
-  monthat <- c()
-  for (i in 1:(length(monthticks) - 1))
-    monthat <- c(monthat, (monthticks[i] + monthticks[i + 1]) / 2 + .5)
+        format(as.POSIXct(dates[monthticks[length(monthticks) - 1] + 1]),
+        ifelse(intervalInd == 3, "%b %d", "%b %y")))
+    if (intervalInd == 3)
+      monthlabels[length(monthlabels)] <- ""
+    monthat <- c()
+    for (i in 1:(length(monthticks) - 1))
+      monthat <- c(monthat, (monthticks[i] + monthticks[i + 1]) / 2 + .5)
 
-  sources <- c("siv", "moria", "torperf")
-  colors <- c("#0000EE", "#EE0000", "#00CD00")
-  sizes <- c("5mb", "1mb", "50kb")
-  sizePrint <- c("5 MiB", "1 MiB", "50 KiB")
+    sources <- c("siv", "moria", "torperf")
+    colors <- c("#0000EE", "#EE0000", "#00CD00")
+    sizes <- c("5mb", "1mb", "50kb")
+    sizePrint <- c("5 MiB", "1 MiB", "50 KiB")
 
-  for (sizeInd in 1:length(sizes)) {
-    size <- sizes[sizeInd]
-    sizePr <- sizePrint[sizeInd]
-    for (sourceInd in 1:length(sources)) {
-      sourceStr <- paste(sources[sourceInd], size, sep = "-")
-      sourceName <- sources[sourceInd]
-      png(paste("website/graphs/torperf/torperf-", size, "-", sourceName,
-          "-", interval, ".png", sep = ""), width=550, height=350)
-      par(mar=c(2.1,3.1,1.6,0.1))
-      maxY <- max(na.omit(subset(t, source %in% paste(sources, size,
-          sep = "-"))$q3)) / 1e3 * .8
-      color <- colors[sourceInd]
-      title <- paste("Time in seconds to complete", sizePr, "request")
-      xlab <- ""
+    for (sizeInd in 1:length(sizes)) {
+      size <- sizes[sizeInd]
+      sizePr <- sizePrint[sizeInd]
+      for (sourceInd in 1:length(sources)) {
+        sourceStr <- paste(sources[sourceInd], size, sep = "-")
+        sourceName <- sources[sourceInd]
+        png(paste("website/graphs/torperf/torperf-", size, "-", sourceName,
+            "-", interval, ".png", sep = ""), width=550, height=350)
+        par(mar=c(2.1,3.1,1.6,0.1))
+        maxY <- max(na.omit(subset(t, source %in% paste(sources, size,
+            sep = "-"))$q3)) / 1e3 * .8
+        color <- colors[sourceInd]
+        title <- paste("Time in seconds to complete", sizePr, "request")
+        xlab <- ""
 
-      data <- subset(t, source %in% sourceStr)
+        data <- subset(t, source %in% sourceStr)
 
-      q1s_ <- c()
-      medians_ <- c()
-      q3s_ <- c()
-      for (i in datesStr) {
-        q1s_ <- c(q1s_, ifelse(i %in% data$date, data$q1[data$date == i],
-            NA))
-        medians_ <- c(medians_, ifelse(i %in% data$date,
-            data$md[data$date == i], NA))
-        q3s_ <- c(q3s_, ifelse(i %in% data$date, data$q3[data$date == i],
-            NA))
-      }
-      colmed <- color
-      colquart <- paste(color, "66", sep="")
+        q1s_ <- c()
+        medians_ <- c()
+        q3s_ <- c()
+        for (i in datesStr) {
+          q1s_ <- c(q1s_, ifelse(i %in% data$date, data$q1[data$date == i],
+              NA))
+          medians_ <- c(medians_, ifelse(i %in% data$date,
+              data$md[data$date == i], NA))
+          q3s_ <- c(q3s_, ifelse(i %in% data$date, data$q3[data$date == i],
+              NA))
+        }
+        colmed <- color
+        colquart <- paste(color, "66", sep="")
 
-      plot(medians_/1e3, ylim=c(0, maxY), type="l", col=colmed, lwd=2,
-          main=title, axes=FALSE, ylab="", xlab=xlab)
+        plot(medians_/1e3, ylim=c(0, maxY), type="l", col=colmed, lwd=2,
+            main=title, axes=FALSE, ylab="", xlab=xlab)
 
-      xp <- c()
-      yp <- c()
-      for (i in 1:length(q1s_)) {
-        if (is.na(q1s_[i])) {
-          if (length(xp) > 0) {
-            for (j in xp[length(xp)]:xp[1]) {
-              xp <- c(xp, j)
-              yp <- c(yp, q3s_[j]/1e3)
+        xp <- c()
+        yp <- c()
+        for (i in 1:length(q1s_)) {
+          if (is.na(q1s_[i])) {
+            if (length(xp) > 0) {
+              for (j in xp[length(xp)]:xp[1]) {
+                xp <- c(xp, j)
+                yp <- c(yp, q3s_[j]/1e3)
+              }
+              polygon(na.omit(xp), na.omit(yp), col=colquart, lty=0)
             }
-            polygon(na.omit(xp), na.omit(yp), col=colquart, lty=0)
+            xp <- c()
+            yp <- c()
+          } else {
+            xp <- c(xp, i)
+            yp <- c(yp, q1s_[i]/1e3)
           }
-          xp <- c()
-          yp <- c()
-        } else {
-          xp <- c(xp, i)
-          yp <- c(yp, q1s_[i]/1e3)
         }
-      }
-      if (length(xp) > 0) {
-        for (j in xp[length(xp)]:xp[1]) {
-          xp <- c(xp, j)
-          yp <- c(yp, q3s_[j]/1e3)
+        if (length(xp) > 0) {
+          for (j in xp[length(xp)]:xp[1]) {
+            xp <- c(xp, j)
+            yp <- c(yp, q3s_[j]/1e3)
+          }
+          polygon(na.omit(xp), na.omit(yp), col=colquart, lty=0)
         }
-        polygon(na.omit(xp), na.omit(yp), col=colquart, lty=0)
-      }
 
-      axis(1, at=monthticks - 0.5, labels=FALSE, lwd=0, lwd.ticks=1)
-      axis(1, at=c(1, length(datesStr)), labels=FALSE, lwd=1, lwd.ticks=0)
-      axis(1, at=monthat, lwd=0, labels=monthlabels)
-      axis(2, las=1, lwd=0, lwd.ticks=1)
-      axis(2, las=1, at=c(0, maxY), lwd.ticks=0, labels=FALSE)
+        axis(1, at=monthticks - 0.5, labels=FALSE, lwd=0, lwd.ticks=1)
+        axis(1, at=c(1, length(datesStr)), labels=FALSE, lwd=1, lwd.ticks=0)
+        axis(1, at=monthat, lwd=0, labels=monthlabels)
+        axis(2, las=1, lwd=0, lwd.ticks=1)
+        axis(2, las=1, at=c(0, maxY), lwd.ticks=0, labels=FALSE)
 
-      legend(title = paste("Measured times on", sourceName, "per day"),
-          x=length(datesStr)/2, xjust=0.5, y=maxY, yjust=1,
-          #cex=ifelse(intervalInd == 1, 1.5, 1),
-          c("Median", "1st to 3rd quartile"), fill=c(colmed, colquart),
-          bty="n", ncol=2)
-      dev.off()
+        legend(title = paste("Measured times on", sourceName, "per day"),
+            x=length(datesStr)/2, xjust=0.5, y=maxY, yjust=1,
+            #cex=ifelse(intervalInd == 1, 1.5, 1),
+            c("Median", "1st to 3rd quartile"), fill=c(colmed, colquart),
+            bty="n", ncol=2)
+        dev.off()
+      }
     }
   }
 }
-- 
1.6.5