@@ -754,25 +754,25 @@ srv_missing_data <- function(id,
754754 env = list (data_keys = data_keys())
755755 )
756756 )
757-
757+
758758 teal.reporter :: teal_card(qenv ) <- append(teal.reporter :: teal_card(qenv ), " ## Summary Plot" )
759-
759+
760760 qenv <- teal.code :: eval_code(
761761 qenv ,
762762 substitute(
763763 expr = summary_plot_obs <- data_frame_call [, analysis_vars ] %> %
764- dplyr :: summarise_all(list (function (x ) sum(is.na(x )))) %> %
765- tidyr :: pivot_longer(dplyr :: everything(), names_to = " col" , values_to = " n_na" ) %> %
766- dplyr :: mutate(n_not_na = nrow(ANL ) - n_na ) %> %
767- tidyr :: pivot_longer(- col , names_to = " isna" , values_to = " n" ) %> %
768- dplyr :: mutate(isna = isna == " n_na" , n_pct = n / nrow(ANL ) * 100 ),
769- env = list (data_frame_call = if (! inherits(data_r(), " tbl_df" )) {
770- quote(tibble :: as_tibble(ANL ))
771- } else {
772- quote(ANL )
773- })
774- )
775- ) %> %
764+ dplyr :: summarise_all(list (function (x ) sum(is.na(x )))) %> %
765+ tidyr :: pivot_longer(dplyr :: everything(), names_to = " col" , values_to = " n_na" ) %> %
766+ dplyr :: mutate(n_not_na = nrow(ANL ) - n_na ) %> %
767+ tidyr :: pivot_longer(- col , names_to = " isna" , values_to = " n" ) %> %
768+ dplyr :: mutate(isna = isna == " n_na" , n_pct = n / nrow(ANL ) * 100 ),
769+ env = list (data_frame_call = if (! inherits(data_r(), " tbl_df" )) {
770+ quote(tibble :: as_tibble(ANL ))
771+ } else {
772+ quote(ANL )
773+ })
774+ )
775+ ) %> %
776776 # x axis ordering according to number of missing values and alphabet
777777 teal.code :: eval_code(
778778 quote(
@@ -1112,7 +1112,7 @@ srv_missing_data <- function(id,
11121112
11131113 qenv <- common_code_q()
11141114 teal.reporter :: teal_card(qenv ) <- append(teal.reporter :: teal_card(qenv ), " ## Summary Table" )
1115-
1115+
11161116 qenv <- if (! is.null(group_var )) {
11171117 common_code_libraries_q <- teal.code :: eval_code(
11181118 qenv ,
@@ -1190,7 +1190,7 @@ srv_missing_data <- function(id,
11901190
11911191 qenv <- common_code_q()
11921192 teal.reporter :: teal_card(qenv ) <- append(teal.reporter :: teal_card(qenv ), " ## By Subject Plot" )
1193-
1193+
11941194 qenv <- teal.code :: eval_code(
11951195 qenv ,
11961196 substitute(
@@ -1244,40 +1244,40 @@ srv_missing_data <- function(id,
12441244 env = list (hashing_function = hashing_function )
12451245 )
12461246 )
1247-
1247+
12481248 qenv <- teal.code :: eval_code(
12491249 qenv ,
12501250 substitute(
12511251 expr = {
12521252 by_subject_plot <- ggplot2 :: ggplot(summary_plot_patients , ggplot2 :: aes(
1253- x = factor (id , levels = order_subjects ),
1254- y = factor (col , levels = ordered_columns [[" column" ]]),
1255- fill = isna
1256- )) +
1257- ggplot2 :: geom_raster() +
1258- ggplot2 :: annotate(
1259- " text" ,
1260- x = length(order_subjects ),
1261- y = seq_len(nrow(ordered_columns )),
1262- hjust = 1 ,
1263- label = sprintf(" %d [%.02f%%]" , ordered_columns [[" na_count" ]], ordered_columns [[" na_percent" ]])
1264- ) +
1265- ggplot2 :: scale_fill_manual(
1266- name = " " ,
1267- values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
1268- labels = c(" Present" , " Missing (at least one)" )
1269- ) +
1270- labs +
1271- ggthemes +
1272- themes
1273- },
1274- env = list (
1275- labs = parsed_ggplot2_args $ labs ,
1276- themes = parsed_ggplot2_args $ theme ,
1277- ggthemes = parsed_ggplot2_args $ ggtheme
1278- )
1253+ x = factor (id , levels = order_subjects ),
1254+ y = factor (col , levels = ordered_columns [[" column" ]]),
1255+ fill = isna
1256+ )) +
1257+ ggplot2 :: geom_raster() +
1258+ ggplot2 :: annotate(
1259+ " text" ,
1260+ x = length(order_subjects ),
1261+ y = seq_len(nrow(ordered_columns )),
1262+ hjust = 1 ,
1263+ label = sprintf(" %d [%.02f%%]" , ordered_columns [[" na_count" ]], ordered_columns [[" na_percent" ]])
1264+ ) +
1265+ ggplot2 :: scale_fill_manual(
1266+ name = " " ,
1267+ values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
1268+ labels = c(" Present" , " Missing (at least one)" )
1269+ ) +
1270+ labs +
1271+ ggthemes +
1272+ themes
1273+ },
1274+ env = list (
1275+ labs = parsed_ggplot2_args $ labs ,
1276+ themes = parsed_ggplot2_args $ theme ,
1277+ ggthemes = parsed_ggplot2_args $ ggtheme
12791278 )
12801279 )
1280+ )
12811281 })
12821282
12831283 # Decorated outputs
@@ -1289,8 +1289,7 @@ srv_missing_data <- function(id,
12891289 decorators = select_decorators(decorators , " summary_plot" ),
12901290 expr = quote({
12911291 summary_plot
1292- }),
1293- keep_output = " summary_plot"
1292+ })
12941293 )
12951294
12961295 decorated_combination_plot_q <- srv_decorate_teal_data(
@@ -1301,24 +1300,21 @@ srv_missing_data <- function(id,
13011300 grid :: grid.newpage()
13021301 grid :: grid.draw(combination_plot )
13031302 combination_plot
1304- }),
1305- keep_output = " combination_plot"
1303+ })
13061304 )
13071305
13081306 decorated_summary_table_q <- srv_decorate_teal_data(
13091307 id = " dec_summary_table" ,
13101308 data = summary_table_q ,
13111309 decorators = select_decorators(decorators , " table" ),
1312- expr = quote(table ),
1313- keep_output = " table"
1310+ expr = quote(table )
13141311 )
13151312
13161313 decorated_by_subject_plot_q <- srv_decorate_teal_data(
13171314 id = " dec_by_subject_plot" ,
13181315 data = by_subject_plot_q ,
13191316 decorators = select_decorators(decorators , " by_subject_plot" ),
1320- expr = quote(by_subject_plot ),
1321- keep_output = " by_subject_plot"
1317+ expr = quote(by_subject_plot )
13221318 )
13231319
13241320 # Plots & tables reactives
0 commit comments