library(ggplot2) library(rjson) details <- fromJSON(file="https://onionoo.torproject.org/details?type=relay") # Convert JSON into a data.frame. relays <- Filter(function(x) { x[["running"]] }, details[["relays"]]) relays <- do.call(rbind, lapply(relays, function(x) { as.data.frame(c( x[c("nickname", "measured", "consensus_weight", "first_seen")], exit=(("Exit" %in% unlist(x["flags"])) & !("BadExit" %in% x["flags"])) )) })) relays$first_seen <- as.POSIXct(relays$first_seen, tz="GMT") p <- ggplot(relays, aes(consensus_weight)) p <- p + stat_ecdf() p <- p + scale_x_log10() p <- p + labs(title=NULL, x="Consensus weight (KB/s)", y="Fraction") ggsave("consensus_weight.png", p, width=7, height=4, dpi=120) p <- ggplot(relays, aes(first_seen, consensus_weight, color=measured)) p <- p + geom_point(alpha=0.2) p <- p + scale_y_log10() p <- p + labs(title=NULL, x="First seen date", y="Consensus weight (KB/s)") p <- p + guides(color=guide_legend(override.aes=c(alpha=1))) ggsave("first_seen.png", p, width=7, height=4, dpi=120)