[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-web/release] Fix unknown issue with spread() function.
commit b3e80fce17f04cf7c83ef3843d2de0cc3bfef389
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Fri May 3 09:28:06 2019 +0200
Fix unknown issue with spread() function.
This is a hotfix to work around the issue described in #30351.
Hopefully, we'll come up with a better fix that doesn't go backwards
from tidyr to reshape2.
---
src/main/R/rserver/rserve-init.R | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/main/R/rserver/rserve-init.R b/src/main/R/rserver/rserve-init.R
index 5a47550..3d6dad7 100644
--- a/src/main/R/rserver/rserve-init.R
+++ b/src/main/R/rserver/rserve-init.R
@@ -1,3 +1,4 @@
+require(reshape2)
require(ggplot2)
require(RColorBrewer)
require(scales)
@@ -436,7 +437,7 @@ prepare_platforms <- function(start_p = NULL, end_p = NULL) {
filter(if (!is.null(start_p)) date >= as.Date(start_p) else TRUE) %>%
filter(if (!is.null(end_p)) date <= as.Date(end_p) else TRUE) %>%
mutate(platform = tolower(platform)) %>%
- spread(platform, relays)
+ dcast(date ~ platform, value.var = "relays")
}
plot_platforms <- function(start_p, end_p, path_p) {
@@ -700,7 +701,7 @@ prepare_connbidirect <- function(start_p = NULL, end_p = NULL) {
filter(if (!is.null(end_p)) date <= as.Date(end_p) else TRUE) %>%
mutate(quantile = paste("X", quantile, sep = ""),
fraction = fraction / 100) %>%
- spread(quantile, fraction) %>%
+ dcast(date + direction ~ quantile, value.var = "fraction") %>%
rename(q1 = X0.25, md = X0.5, q3 = X0.75)
}
@@ -752,7 +753,8 @@ prepare_bandwidth_flags <- function(start_p = NULL, end_p = NULL) {
filter(if (!is.null(end_p)) date <= as.Date(end_p) else TRUE) %>%
filter(!is.na(have_exit_flag)) %>%
filter(!is.na(have_guard_flag)) %>%
- spread(variable, value)
+ dcast(date + have_guard_flag + have_exit_flag ~ variable,
+ value.var = "value")
}
plot_bandwidth_flags <- function(start_p, end_p, path_p) {
@@ -1058,7 +1060,7 @@ prepare_advbwdist_perc <- function(start_p = NULL, end_p = NULL, p_p = NULL) {
transmute(date, percentile = as.factor(percentile),
variable = ifelse(is.na(isexit), "all", "exits"),
advbw = advbw * 8 / 1e9) %>%
- spread(variable, advbw) %>%
+ dcast(date + percentile ~ variable, value.var = "advbw") %>%
rename(p = percentile)
}
@@ -1096,7 +1098,7 @@ prepare_advbwdist_relay <- function(start_p = NULL, end_p = NULL, n_p = NULL) {
transmute(date, relay = as.factor(relay),
variable = ifelse(is.na(isexit), "all", "exits"),
advbw = advbw * 8 / 1e9) %>%
- spread(variable, advbw) %>%
+ dcast(date + relay ~ variable, value.var = "advbw") %>%
rename(n = relay)
}
@@ -1194,7 +1196,7 @@ prepare_webstats_tb <- function(start_p = NULL, end_p = NULL) {
filter(request_type %in% c("tbid", "tbsd", "tbup", "tbur")) %>%
group_by(log_date, request_type) %>%
summarize(count = sum(count)) %>%
- spread(request_type, count) %>%
+ dcast(log_date ~ request_type, value.var = "count") %>%
rename(date = log_date, initial_downloads = tbid,
signature_downloads = tbsd, update_pings = tbup,
update_requests = tbur)
@@ -1239,7 +1241,7 @@ prepare_webstats_tb_platform <- function(start_p = NULL, end_p = NULL) {
filter(request_type %in% c("tbid", "tbup")) %>%
group_by(log_date, platform, request_type) %>%
summarize(count = sum(count)) %>%
- spread(request_type, count, fill = 0) %>%
+ dcast(log_date + platform ~ request_type, value.var = "count") %>%
rename(date = log_date, initial_downloads = tbid, update_pings = tbup)
}
@@ -1287,7 +1289,7 @@ prepare_webstats_tb_locale <- function(start_p = NULL, end_p = NULL) {
group_by(date, locale, request_type) %>%
summarize(count = sum(count)) %>%
mutate(request_type = factor(request_type, levels = c("tbid", "tbup"))) %>%
- spread(request_type, count, fill = 0) %>%
+ dcast(date + locale ~ request_type, value.var = "count") %>%
rename(initial_downloads = tbid, update_pings = tbup)
}
@@ -1342,7 +1344,8 @@ prepare_webstats_tm <- function(start_p = NULL, end_p = NULL) {
group_by(log_date, request_type) %>%
summarize(count = sum(count)) %>%
mutate(request_type = factor(request_type, levels = c("tmid", "tmup"))) %>%
- spread(request_type, count, drop = FALSE, fill = 0) %>%
+ dcast(log_date ~ request_type, value.var = "count", drop = FALSE,
+ fill = 0) %>%
rename(date = log_date, initial_downloads = tmid, update_pings = tmup)
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits