12
12
# ' @export
13
13
orgmetrics_dashboard <- function (data_org , data_users , action = " preview" ) {
14
14
15
+ data_org <- data_org_preprocess (data_org )
16
+
15
17
requireNamespace (" brio" )
16
18
requireNamespace (" jsonlite" )
17
19
requireNamespace (" quarto" )
@@ -23,8 +25,29 @@ orgmetrics_dashboard <- function (data_org, data_users, action = "preview") {
23
25
path_src <- system.file (" extdata" , " quarto-org" , package = " repometrics" )
24
26
path_dest <- fs :: path (fs :: path_temp (), " quarto-org" )
25
27
dir <- fs :: dir_copy (path_src , path_dest , overwrite = TRUE )
28
+ saveRDS (data_org , fs :: path (dir , " results-org.Rds" ))
26
29
27
30
withr :: with_dir (dir , {
28
31
do.call (eval (parse (text = quarto_action )), list ())
29
32
})
30
33
}
34
+
35
+ # ' Pre-process organization data by converting all model values to standard
36
+ # ' z-scores, retrieving the latest value only for each package, and generating
37
+ # ' a "final" score from the sum across all model scores. Higher values of this
38
+ # ' final score are better than lower values.
39
+ # ' @noRd
40
+ data_org_preprocess <- function (data_org ) {
41
+
42
+ data_org | >
43
+ dplyr :: mutate (
44
+ dplyr :: across (dplyr :: where (is.numeric ), ~ scale (. ) [, 1 ])
45
+ ) | >
46
+ dplyr :: group_by (package ) | >
47
+ dplyr :: slice_head (n = 1L ) | >
48
+ dplyr :: mutate (
49
+ final = sum (dplyr :: across (dplyr :: where (is.numeric ))),
50
+ .after = " date"
51
+ ) | >
52
+ dplyr :: arrange (dplyr :: desc (final ))
53
+ }
0 commit comments