Bearloga has submitted this change and it was merged.

Change subject: Add a selector wrapper
......................................................................


Add a selector wrapper

This adds a little selector wrapper we can use to generate input selectors
to specify the level of smoothing or aggregation that should be applied
to a visualised time series. It also modifies the code used for 'smoothing'
to apply the median, rather than mean

Bug: T107202
Change-Id: Idb84a8d8b100789f1fe19a45bd09f914409c135c
---
M utils.R
1 file changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Bearloga: Verified; Looks good to me, approved



diff --git a/utils.R b/utils.R
index bb25f2d..ccf03ed 100644
--- a/utils.R
+++ b/utils.R
@@ -158,7 +158,7 @@
                     # Construct output names for the averages, compute those 
averages, and
                     # apply said names.
                     output_names <- paste(names(df)[2:(ncol(df) - 2)], 
name_append)
-                    holding <- as.data.frame(t(colMeans(df[,2:(ncol(df) - 
2)])))
+                    holding <- as.data.frame(t(round(apply(df[,2:(ncol(df) - 
2)], 2, FUN = median))))
                     names(holding) <- output_names
 
                     # Return the bound original values and averaged values
@@ -167,3 +167,11 @@
 
   return(result[,!names(result) %in% c("filter_1","filter_2")])
 }
+
+# Standardised input selector for smoothing
+standard_select <- function(input_id){
+  return(
+    shiny::selectInput(inputId = input_id, label = "Smoothing",
+                       choices = c("no smoothing","weekly median","monthly 
median"), selected = "day")
+  )
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/236811
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb84a8d8b100789f1fe19a45bd09f914409c135c
Gerrit-PatchSet: 3
Gerrit-Project: wikimedia/discovery/rainbow
Gerrit-Branch: master
Gerrit-Owner: OliverKeyes <[email protected]>
Gerrit-Reviewer: Bearloga <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to