@@ -535,18 +535,21 @@ srv_missing_data <- function(id,
535535
536536 group_var <- input $ group_by_var
537537 anl <- data_r()
538+ qenv <- teal.code :: eval_code(data(), {
539+ " library('dplyr');library('ggplot2');library('tidyr');library('forcats');library('glue')"
540+ })
538541
539542 qenv <- if (! is.null(selected_vars()) && length(selected_vars()) != ncol(anl )) {
540543 teal.code :: eval_code(
541- data() ,
544+ qenv ,
542545 substitute(
543546 expr = ANL <- anl_name [, selected_vars , drop = FALSE ],
544547 env = list (anl_name = as.name(dataname ), selected_vars = selected_vars())
545548 )
546549 )
547550 } else {
548551 teal.code :: eval_code(
549- data() ,
552+ qenv ,
550553 substitute(expr = ANL <- anl_name , env = list (anl_name = as.name(dataname )))
551554 )
552555 }
@@ -790,7 +793,7 @@ srv_missing_data <- function(id,
790793
791794 dev_ggplot2_args <- teal.widgets :: ggplot2_args(
792795 labs = list (x = " Variable" , y = " Missing observations" ),
793- theme = list (legend.position = " bottom" , axis.text.x = quote(element_text(angle = 45 , hjust = 1 )))
796+ theme = list (legend.position = " bottom" , axis.text.x = quote(ggplot2 :: element_text(angle = 45 , hjust = 1 )))
794797 )
795798
796799 all_ggplot2_args <- teal.widgets :: resolve_ggplot2_args(
@@ -808,32 +811,32 @@ srv_missing_data <- function(id,
808811 qenv ,
809812 substitute(
810813 summary_plot_top <- summary_plot_obs %> %
811- ggplot() +
812- aes(
814+ ggplot2 :: ggplot() +
815+ ggplot2 :: aes(
813816 x = factor (create_cols_labels(col ), levels = x_levels ),
814817 y = n_pct ,
815818 fill = isna
816819 ) +
817- geom_bar(position = " fill" , stat = " identity" ) +
818- scale_fill_manual(
820+ ggplot2 :: geom_bar(position = " fill" , stat = " identity" ) +
821+ ggplot2 :: scale_fill_manual(
819822 name = " " ,
820823 values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
821824 labels = c(" Present" , " Missing" )
822825 ) +
823- scale_y_continuous(
826+ ggplot2 :: scale_y_continuous(
824827 labels = scales :: percent_format(),
825828 breaks = seq(0 , 1 , by = 0.1 ),
826829 expand = c(0 , 0 )
827830 ) +
828- geom_text(
829- aes(label = ifelse(isna == TRUE , sprintf(" %d [%.02f%%]" , n , n_pct ), " " ), y = 1 ),
831+ ggplot2 :: geom_text(
832+ ggplot2 :: aes(label = ifelse(isna == TRUE , sprintf(" %d [%.02f%%]" , n , n_pct ), " " ), y = 1 ),
830833 hjust = 1 ,
831834 color = " black"
832835 ) +
833836 labs +
834837 ggthemes +
835838 themes +
836- coord_flip(),
839+ ggplot2 :: coord_flip(),
837840 env = list (
838841 labs = parsed_ggplot2_args $ labs ,
839842 themes = parsed_ggplot2_args $ theme ,
@@ -870,8 +873,8 @@ srv_missing_data <- function(id,
870873 labs = list (x = " " , y = " Missing patients" ),
871874 theme = list (
872875 legend.position = " bottom" ,
873- axis.text.x = quote(element_text(angle = 45 , hjust = 1 )),
874- axis.text.y = quote(element_blank())
876+ axis.text.x = quote(ggplot2 :: element_text(angle = 45 , hjust = 1 )),
877+ axis.text.y = quote(ggplot2 :: element_blank())
875878 )
876879 )
877880
@@ -890,32 +893,32 @@ srv_missing_data <- function(id,
890893 qenv ,
891894 substitute(
892895 summary_plot_bottom <- summary_plot_patients %> %
893- ggplot() +
894- aes_(
896+ ggplot2 :: ggplot() +
897+ ggplot2 :: aes_(
895898 x = ~ factor (create_cols_labels(col ), levels = x_levels ),
896899 y = ~ n_pct ,
897900 fill = ~ isna
898901 ) +
899- geom_bar(alpha = 1 , stat = " identity" , position = " fill" ) +
900- scale_y_continuous(
902+ ggplot2 :: geom_bar(alpha = 1 , stat = " identity" , position = " fill" ) +
903+ ggplot2 :: scale_y_continuous(
901904 labels = scales :: percent_format(),
902905 breaks = seq(0 , 1 , by = 0.1 ),
903906 expand = c(0 , 0 )
904907 ) +
905- scale_fill_manual(
908+ ggplot2 :: scale_fill_manual(
906909 name = " " ,
907910 values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
908911 labels = c(" Present" , " Missing" )
909912 ) +
910- geom_text(
911- aes(label = ifelse(isna == TRUE , sprintf(" %d [%.02f%%]" , n , n_pct ), " " ), y = 1 ),
913+ ggplot2 :: geom_text(
914+ ggplot2 :: aes(label = ifelse(isna == TRUE , sprintf(" %d [%.02f%%]" , n , n_pct ), " " ), y = 1 ),
912915 hjust = 1 ,
913916 color = " black"
914917 ) +
915918 labs +
916919 ggthemes +
917920 themes +
918- coord_flip(),
921+ ggplot2 :: coord_flip(),
919922 env = list (
920923 labs = parsed_ggplot2_args $ labs ,
921924 themes = parsed_ggplot2_args $ theme ,
@@ -982,7 +985,7 @@ srv_missing_data <- function(id,
982985 labs = list (x = " " , y = " " ),
983986 theme = list (
984987 legend.position = " bottom" ,
985- axis.text.x = quote(element_blank())
988+ axis.text.x = quote(ggplot2 :: element_blank())
986989 )
987990 )
988991
@@ -1001,9 +1004,9 @@ srv_missing_data <- function(id,
10011004 labs = list (x = " " , y = " " ),
10021005 theme = list (
10031006 legend.position = " bottom" ,
1004- axis.text.x = quote(element_blank()),
1005- axis.ticks = quote(element_blank()),
1006- panel.grid.major = quote(element_blank())
1007+ axis.text.x = quote(ggplot2 :: element_blank()),
1008+ axis.ticks = quote(ggplot2 :: element_blank()),
1009+ panel.grid.major = quote(ggplot2 :: element_blank())
10071010 )
10081011 )
10091012
@@ -1025,32 +1028,32 @@ srv_missing_data <- function(id,
10251028 combination_plot_top <- data_combination_plot_cutoff %> %
10261029 dplyr :: select(id , n ) %> %
10271030 dplyr :: distinct() %> %
1028- ggplot(aes(x = id , y = n )) +
1029- geom_bar(stat = " identity" , fill = c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]) +
1030- geom_text(
1031- aes(label = n ),
1032- position = position_dodge(width = 0.9 ),
1031+ ggplot2 :: ggplot(ggplot2 :: aes(x = id , y = n )) +
1032+ ggplot2 :: geom_bar(stat = " identity" , fill = c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]) +
1033+ ggplot2 :: geom_text(
1034+ ggplot2 :: aes(label = n ),
1035+ position = ggplot2 :: position_dodge(width = 0.9 ),
10331036 vjust = - 0.25
10341037 ) +
1035- ylim(c(0 , max(data_combination_plot_cutoff $ n ) * 1.5 )) +
1038+ ggplot2 :: ylim(c(0 , max(data_combination_plot_cutoff $ n ) * 1.5 )) +
10361039 labs1 +
10371040 ggthemes1 +
10381041 themes1
10391042
10401043 graph_number_rows <- length(unique(data_combination_plot_cutoff $ id ))
10411044 graph_number_cols <- nrow(data_combination_plot_cutoff ) / graph_number_rows
10421045
1043- combination_plot_bottom <- data_combination_plot_cutoff %> % ggplot() +
1044- aes(x = create_cols_labels(key ), y = id - 0.5 , fill = value ) +
1045- geom_tile(alpha = 0.85 , height = 0.95 ) +
1046- scale_fill_manual(
1046+ combination_plot_bottom <- data_combination_plot_cutoff %> % ggplot2 :: ggplot() +
1047+ ggplot2 :: aes(x = create_cols_labels(key ), y = id - 0.5 , fill = value ) +
1048+ ggplot2 :: geom_tile(alpha = 0.85 , height = 0.95 ) +
1049+ ggplot2 :: scale_fill_manual(
10471050 name = " " ,
10481051 values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
10491052 labels = c(" Present" , " Missing" )
10501053 ) +
1051- geom_hline(yintercept = seq_len(1 + graph_number_rows ) - 1 ) +
1052- geom_vline(xintercept = seq_len(1 + graph_number_cols ) - 0.5 , linetype = " dotted" ) +
1053- coord_flip() +
1054+ ggplot2 :: geom_hline(yintercept = seq_len(1 + graph_number_rows ) - 1 ) +
1055+ ggplot2 :: geom_vline(xintercept = seq_len(1 + graph_number_cols ) - 0.5 , linetype = " dotted" ) +
1056+ ggplot2 :: coord_flip() +
10541057 labs2 +
10551058 ggthemes2 +
10561059 themes2
@@ -1161,7 +1164,7 @@ srv_missing_data <- function(id,
11611164
11621165 dev_ggplot2_args <- teal.widgets :: ggplot2_args(
11631166 labs = list (x = " " , y = " " ),
1164- theme = list (legend.position = " bottom" , axis.text.x = quote(element_blank()))
1167+ theme = list (legend.position = " bottom" , axis.text.x = quote(ggplot2 :: element_blank()))
11651168 )
11661169
11671170 all_ggplot2_args <- teal.widgets :: resolve_ggplot2_args(
@@ -1238,20 +1241,20 @@ srv_missing_data <- function(id,
12381241 teal.code :: eval_code(
12391242 substitute(
12401243 expr = {
1241- by_subject_plot <- ggplot(summary_plot_patients , aes(
1244+ by_subject_plot <- ggplot2 :: ggplot(summary_plot_patients , aes(
12421245 x = factor (id , levels = order_subjects ),
12431246 y = factor (col , levels = ordered_columns [[" column" ]]),
12441247 fill = isna
12451248 )) +
1246- geom_raster() +
1247- annotate(
1249+ ggplot2 :: geom_raster() +
1250+ ggplot2 :: annotate(
12481251 " text" ,
12491252 x = length(order_subjects ),
12501253 y = seq_len(nrow(ordered_columns )),
12511254 hjust = 1 ,
12521255 label = sprintf(" %d [%.02f%%]" , ordered_columns [[" na_count" ]], ordered_columns [[" na_percent" ]])
12531256 ) +
1254- scale_fill_manual(
1257+ ggplot2 :: scale_fill_manual(
12551258 name = " " ,
12561259 values = c(" grey90" , c(getOption(" ggplot2.discrete.colour" )[2 ], " #ff2951ff" )[1 ]),
12571260 labels = c(" Present" , " Missing (at least one)" )
0 commit comments