forked from arthuredelstein/metrics-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatin-america.r
32 lines (25 loc) · 983 Bytes
/
latin-america.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require(ggplot2)
# Load data
b <- read.csv("clients.csv", stringsAsFactors = FALSE)
summary(b)
# Filter by latin american countries
b <- b[b$country %in% c("ar", "bo", "br", "cl", "cr", "do", "ec", "sv", "gt", "hn", "mx", "pa", "py", "pe", "sr", "uy", "ve", "gy", "gf", "ni", "cu"),]
summary(b)
# Plot per country
ggplot(b, aes(x = as.Date(date, "%Y-%m-%d"), y = clients, colour = country)) +
# geom_point() +
geom_line() +
ggtitle("Latin American Tor clients by Country") +
scale_x_date(name = "Date") +
# scale_y_log10() +
facet_grid(node~.,scales = "free_y")
# Aggregated data from all countries
d <- aggregate(list(clients = b$clients), by = list(date = b$date, node = b$node), FUN = sum)
summary(d)
# Plot aggregated data from all countries
ggplot(d, aes(x = as.Date(date, "%Y-%m-%d"), y = clients, colour = node)) +
geom_line() +
ggtitle("Latin American Tor clients") +
scale_x_date(name = "Date") +
# facet_grid(node~.,scales = "free_y") +
expand_limits(y = 0)