[or-cvs] [metrics-db/master] Add graphs for all users, not by country.
karsten at torproject.org
karsten at torproject.org
Mon Aug 16 14:18:04 UTC 2010
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Mon, 16 Aug 2010 16:17:30 +0200
Subject: Add graphs for all users, not by country.
Commit: abe7cda6aa9b057308e4a27ea511da5d9210db44
---
R/bridge-stats.R | 41 +++++++++++++++++++++++++++++------------
R/dirreq-stats.R | 49 ++++++++++++++++++++++++++++++++++++-------------
2 files changed, 65 insertions(+), 25 deletions(-)
diff --git a/R/bridge-stats.R b/R/bridge-stats.R
index fc78477..84bfb65 100644
--- a/R/bridge-stats.R
+++ b/R/bridge-stats.R
@@ -14,31 +14,37 @@ plot_bridges <- function(filename, title, limits, code) {
}
plot_alldata <- function(countries) {
+ end <- Sys.Date()
+ start <- as.Date(bridge$date[1])
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- end <- Sys.Date()
- start <- as.Date(bridge$date[1])
plot_bridges(paste(filename, "-bridges-all.png", sep = ""),
paste(people, "Tor users via bridges (all data)\n"),
c(start, end), code)
}
+ plot_bridges(paste("total-bridges-all.png", sep = ""),
+ paste("Total Tor users via bridges (all data)\n"),
+ c(start, end), "all")
}
plot_pastdays <- function(days, countries) {
for (day in days) {
+ end <- Sys.Date()
+ start <- seq(from = end, length = 2, by = paste("-", day, " days",
+ sep = ""))[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- end <- Sys.Date()
- start <- seq(from = end, length = 2, by = paste("-", day, " days",
- sep = ""))[2]
plot_bridges(paste(filename, "-bridges-", day, "d.png", sep = ""),
paste(people, "Tor users via bridges (past", day, "days)\n"),
c(start, end), code)
}
+ plot_bridges(paste("total-bridges-", day, "d.png", sep = ""),
+ paste("Total Tor users via bridges (past", day, "days)\n"),
+ c(start, end), "all")
}
}
@@ -53,24 +59,31 @@ plot_years <- function(years, countries) {
as.Date(c(paste(year, "-01-01", sep = ""), paste(year, "-12-31",
sep = ""))), code)
}
+ plot_bridges(paste("total-bridges-", year, ".png", sep = ""),
+ paste("Total Tor users via bridges (", year, ")\n", sep = ""),
+ as.Date(c(paste(year, "-01-01", sep = ""), paste(year, "-12-31",
+ sep = ""))), "all")
}
}
plot_quarters <- function(years, quarters, countries) {
for (year in years) {
for (quarter in quarters) {
+ start <- as.Date(paste(year, "-", (quarter - 1) * 3 + 1, "-01",
+ sep = ""))
+ end <- seq(seq(start, length = 2, by = "3 months")[2], length = 2,
+ by = "-1 day")[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- start <- as.Date(paste(year, "-", (quarter - 1) * 3 + 1, "-01",
- sep = ""))
- end <- seq(seq(start, length = 2, by = "3 months")[2], length = 2,
- by = "-1 day")[2]
plot_bridges(paste(filename, "-bridges-", year, "-q", quarter,
".png", sep = ""), paste(people, " Tor users via bridges (Q",
quarter, " ", year, ")\n", sep = ""), c(start, end), code)
}
+ plot_bridges(paste("total-bridges-", year, "-q", quarter, ".png",
+ sep = ""), paste("Total Tor users via bridges (Q", quarter, " ",
+ year, ")\n", sep = ""), c(start, end), "all")
}
}
}
@@ -78,18 +91,22 @@ plot_quarters <- function(years, quarters, countries) {
plot_months <- function(years, months, countries) {
for (year in years) {
for (month in months) {
+ start <- as.Date(paste(year, "-", month, "-01", sep = ""))
+ end <- seq(seq(start, length = 2, by = "1 month")[2], length = 2,
+ by = "-1 day")[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- start <- as.Date(paste(year, "-", month, "-01", sep = ""))
- end <- seq(seq(start, length = 2, by = "1 month")[2], length = 2,
- by = "-1 day")[2]
plot_bridges(paste(filename, "-bridges-", year, "-",
format(start, "%m"), ".png", sep = ""), paste(people,
" Tor users via bridges (", format(start, "%B"), " ", year,
")\n", sep = ""), c(start, end), code)
}
+ plot_bridges(paste("total-bridges-", year, "-", format(start, "%m"),
+ ".png", sep = ""), paste("Total Tor users via bridges (",
+ format(start, "%B"), " ", year, ")\n", sep = ""), c(start, end),
+ "all")
}
}
}
diff --git a/R/dirreq-stats.R b/R/dirreq-stats.R
index a9b48e6..eedaf03 100644
--- a/R/dirreq-stats.R
+++ b/R/dirreq-stats.R
@@ -1,13 +1,17 @@
options(warn = -1)
suppressPackageStartupMessages(library("ggplot2"))
+formatter <- function(x, ...) {
+ format(x, scientific = 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)) +
geom_line() +
scale_x_date(name = "\nThe Tor Project - https://metrics.torproject.org/",
limits = limits) +
- scale_y_continuous(name = "",
+ scale_y_continuous(name = "", formatter = formatter,
limits = c(0, max(c$users, na.rm = TRUE))) +
opts(title = title)
ggsave(filename = paste(directory, filename, sep = ""),
@@ -16,32 +20,38 @@ plot_dirreq <- function(directory, filename, title, limits, data, code) {
plot_alldata <- function(directory, filenamePart, titlePart, data,
countries) {
+ end <- Sys.Date()
+ start <- as.Date(data$date[1])
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- end <- Sys.Date()
- start <- as.Date(data$date[1])
plot_dirreq(directory, paste(filename, filenamePart, "-all.png",
sep = ""), paste(titlePart, people, "Tor users (all data)\n"),
c(start, end), data, code)
}
+ plot_dirreq(directory, paste("total", filenamePart, "-all.png",
+ sep = ""), paste("Total", tolower(titlePart),
+ "Tor users (all data)\n"), c(start, end), data, "all")
}
plot_pastdays <- function(directory, filenamePart, titlePart, days, data,
countries) {
for (day in days) {
+ end <- Sys.Date()
+ start <- seq(from = end, length = 2, by = paste("-", day, " days",
+ sep = ""))[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- end <- Sys.Date()
- start <- seq(from = end, length = 2, by = paste("-", day, " days",
- sep = ""))[2]
plot_dirreq(directory, paste(filename, filenamePart, "-", day,
"d.png", sep = ""), paste(titlePart, people, "Tor users (past",
day, "days)\n"), c(start, end), data, code)
}
+ plot_dirreq(directory, paste("total", filenamePart, "-", day,
+ "d.png", sep = ""), paste("Total", tolower(titlePart),
+ "Tor users (past", day, "days)\n"), c(start, end), data, "all")
}
}
@@ -57,6 +67,11 @@ plot_years <- function(directory, filenamePart, titlePart, years, data,
year, ")\n", sep = ""), as.Date(c(paste(year, "-01-01", sep = ""),
paste(year, "-12-31", sep = ""))), data, code)
}
+ plot_dirreq(directory, paste("total", filenamePart, "-", year,
+ ".png", sep = ""), paste("Total ", tolower(titlePart),
+ " Tor users (", year, ")\n", sep = ""),
+ as.Date(c(paste(year, "-01-01", sep = ""),
+ paste(year, "-12-31", sep = ""))), data, "all")
}
}
@@ -64,19 +79,23 @@ plot_quarters <- function(directory, filenamePart, titlePart, years,
quarters, data, countries) {
for (year in years) {
for (quarter in quarters) {
+ start <- as.Date(paste(year, "-", (quarter - 1) * 3 + 1, "-01",
+ sep = ""))
+ end <- seq(seq(start, length = 2, by = "3 months")[2], length = 2,
+ by = "-1 day")[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- start <- as.Date(paste(year, "-", (quarter - 1) * 3 + 1, "-01",
- sep = ""))
- end <- seq(seq(start, length = 2, by = "3 months")[2], length = 2,
- by = "-1 day")[2]
plot_dirreq(directory, paste(filename, filenamePart, "-", year,
"-q", quarter, ".png", sep = ""), paste(titlePart, " ", people,
" Tor users (Q", quarter, " ", year, ")\n", sep = ""),
c(start, end), data, code)
}
+ plot_dirreq(directory, paste("total", filenamePart, "-", year,
+ "-q", quarter, ".png", sep = ""), paste("Total ",
+ tolower(titlePart), " Tor users (Q", quarter, " ", year, ")\n",
+ sep = ""), c(start, end), data, "all")
}
}
}
@@ -85,18 +104,22 @@ plot_months <- function(directory, filenamePart, titlePart, years, months,
data, countries) {
for (year in years) {
for (month in months) {
+ start <- as.Date(paste(year, "-", month, "-01", sep = ""))
+ end <- seq(seq(start, length = 2, by = "1 month")[2], length = 2,
+ by = "-1 day")[2]
for (country in 1:length(countries$code)) {
code <- countries[country, 1]
people <- countries[country, 2]
filename <- countries[country, 3]
- start <- as.Date(paste(year, "-", month, "-01", sep = ""))
- end <- seq(seq(start, length = 2, by = "1 month")[2], length = 2,
- by = "-1 day")[2]
plot_dirreq(directory, paste(filename, filenamePart, "-", year,
"-", format(start, "%m"), ".png", sep = ""), paste(titlePart,
" ", people, " Tor users (", format(start, "%B"), " ", year,
")\n", sep = ""), c(start, end), data, code)
}
+ plot_dirreq(directory, paste("total", filenamePart, "-", year, "-",
+ format(start, "%m"), ".png", sep = ""), paste("Total ",
+ tolower(titlePart), " Tor users (", format(start, "%B"), " ",
+ year, ")\n", sep = ""), c(start, end), data, "all")
}
}
}
--
1.7.1
More information about the tor-commits
mailing list