Skip to content

Commit 38eb4a5

Browse files
committed
use_evaluate WIP
1 parent ba0e71e commit 38eb4a5

12 files changed

+76
-102
lines changed

R/tm_a_pca.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ srv_a_pca <- function(id, data, dat, plot_height, plot_width, ggplot2_args, deco
517517
quote({
518518
tbl_importance <- dplyr::as_tibble(pca$importance, rownames = "Metric")
519519
tbl_importance
520-
}),
521-
keep_output = "tbl_importance"
520+
})
522521
)
523522

524523
teal.reporter::teal_card(qenv) <- append(teal.reporter::teal_card(qenv), "## Eigenvectors Table")
@@ -528,8 +527,7 @@ srv_a_pca <- function(id, data, dat, plot_height, plot_width, ggplot2_args, deco
528527
quote({
529528
tbl_eigenvector <- dplyr::as_tibble(pca$rotation, rownames = "Variable")
530529
tbl_eigenvector
531-
}),
532-
keep_output = "tbl_eigenvector"
530+
})
533531
)
534532
})
535533

@@ -1044,8 +1042,7 @@ srv_a_pca <- function(id, data, dat, plot_height, plot_width, ggplot2_args, deco
10441042
decorators = select_decorators(decorators, obj_name),
10451043
expr = reactive({
10461044
substitute(.plot, env = list(.plot = as.name(obj_name)))
1047-
}),
1048-
keep_output = obj_name
1045+
})
10491046
)
10501047
},
10511048
names(output_q),

R/tm_a_regression.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ srv_a_regression <- function(id,
536536
teal.code::eval_code(quote({
537537
fit_summary <- summary(fit)
538538
fit_summary
539-
}), keep_output = "fit_summary")
539+
}))
540540
teal.reporter::teal_card(anl_fit) <- append(teal.reporter::teal_card(anl_fit), "## Plot")
541541
anl_fit
542542
})
@@ -1000,8 +1000,7 @@ srv_a_regression <- function(id,
10001000
"decorator",
10011001
data = output_q,
10021002
decorators = select_decorators(decorators, "plot"),
1003-
expr = quote(plot),
1004-
keep_output = "plot"
1003+
expr = quote(plot)
10051004
)
10061005

10071006
fitted <- reactive({
@@ -1024,9 +1023,7 @@ srv_a_regression <- function(id,
10241023
output$text <- renderText({
10251024
req(iv_r()$is_valid())
10261025
req(iv_out$is_valid())
1027-
paste(utils::capture.output(summary(teal.code::dev_suppress(fitted())))[-1],
1028-
collapse = "\n"
1029-
)
1026+
paste(utils::capture.output(summary(fitted()))[-1], collapse = "\n")
10301027
})
10311028

10321029
# Render R code.

R/tm_g_association.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ srv_tm_g_association <- function(id,
492492
)
493493
)
494494
}
495-
obj <- merged$anl_q_r()
495+
obj <- merged$anl_q_r()
496496
teal.reporter::teal_card(obj) <- append(teal.reporter::teal_card(obj), "## Plot")
497497
teal.code::eval_code(
498498
obj,
@@ -522,8 +522,7 @@ srv_tm_g_association <- function(id,
522522
id = "decorator",
523523
data = output_q,
524524
decorators = select_decorators(decorators, "plot"),
525-
expr = quote(plot),
526-
keep_output = "plot"
525+
expr = quote(plot)
527526
)
528527

529528
plot_r <- reactive({
@@ -538,9 +537,7 @@ srv_tm_g_association <- function(id,
538537
width = plot_width
539538
)
540539

541-
output$title <- renderText({
542-
teal.code::dev_suppress(output_q()[["title"]])
543-
})
540+
output$title <- renderText(output_q()[["title"]])
544541

545542
# Render R code.
546543
source_code_r <- reactive(teal.code::get_code(req(decorated_output_grob_q())))

R/tm_g_bivariate.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,7 @@ srv_g_bivariate <- function(id,
728728
)
729729
}
730730
print_call
731-
}),
732-
keep_output = "plot"
731+
})
733732
)
734733

735734
plot_r <- reactive(req(decorated_output_q_facets())[["plot"]])

R/tm_g_distribution.R

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ srv_distribution <- function(id,
637637

638638
obj <- merged$anl_q_r()
639639
teal.reporter::teal_card(obj) <- append(teal.reporter::teal_card(obj), "# Distribution Plot", after = 0)
640-
640+
641641
ANL <- obj[["ANL"]]
642642
dist_var <- merge_vars()$dist_var
643643
s_var <- merge_vars()$s_var
@@ -1297,32 +1297,28 @@ srv_distribution <- function(id,
12971297
"d_density",
12981298
data = output_dist_q,
12991299
decorators = select_decorators(decorators, "histogram_plot"),
1300-
expr = quote(histogram_plot),
1301-
keep_output = "histogram_plot"
1300+
expr = quote(histogram_plot)
13021301
)
13031302

13041303
decorated_output_qq_q <- srv_decorate_teal_data(
13051304
"d_qq",
13061305
data = output_qq_q,
13071306
decorators = select_decorators(decorators, "qq_plot"),
1308-
expr = quote(qq_plot),
1309-
keep_output = "qq_plot"
1307+
expr = quote(qq_plot)
13101308
)
13111309

13121310
decorated_output_summary_q <- srv_decorate_teal_data(
13131311
"d_summary",
13141312
data = output_summary_q,
13151313
decorators = select_decorators(decorators, "summary_table"),
1316-
expr = quote(summary_table),
1317-
keep_output = "summary_table"
1314+
expr = quote(summary_table)
13181315
)
13191316

13201317
decorated_output_test_q <- srv_decorate_teal_data(
13211318
"d_test",
13221319
data = output_test_q,
13231320
decorators = select_decorators(decorators, "test_table"),
1324-
expr = quote(test_table),
1325-
keep_output = "test_table"
1321+
expr = quote(test_table)
13261322
)
13271323

13281324
decorated_output_q <- reactive({

R/tm_g_response.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,7 @@ srv_g_response <- function(id,
576576
id = "decorator",
577577
data = output_q,
578578
decorators = select_decorators(decorators, "plot"),
579-
expr = quote(plot),
580-
keep_output = "plot"
579+
expr = quote(plot)
581580
)
582581

583582
plot_r <- reactive(req(decorated_output_plot_q())[["plot"]])

R/tm_g_scatterplot.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ ui_g_scatterplot <- function(id, ...) {
372372
DT::dataTableOutput(ns("data_table"), width = "100%")
373373
),
374374
encoding = tags$div(
375-
tags$label("Encodings", class = "text-primary"),
375+
tags$label("Encodings", class = "text-primary"),
376376
teal.transform::datanames_input(args[c("x", "y", "color_by", "size_by", "row_facet", "col_facet")]),
377377
teal.transform::data_extract_ui(
378378
id = ns("x"),
@@ -1020,8 +1020,7 @@ srv_g_scatterplot <- function(id,
10201020
id = "decorator",
10211021
data = output_q,
10221022
decorators = select_decorators(decorators, "plot"),
1023-
expr = quote(plot),
1024-
keep_output = "plot"
1023+
expr = quote(plot)
10251024
)
10261025

10271026
plot_r <- reactive(req(decorated_output_plot_q())[["plot"]])
@@ -1042,7 +1041,7 @@ srv_g_scatterplot <- function(id,
10421041
validate(need(!input$add_density, "Brushing feature is currently not supported when plot has marginal density"))
10431042
}
10441043

1045-
merged_data <- isolate(teal.code::dev_suppress(output_q()[["ANL"]]))
1044+
merged_data <- isolate(output_q()[["ANL"]])
10461045

10471046
brushed_df <- teal.widgets::clean_brushedPoints(merged_data, plot_brush)
10481047
numeric_cols <- names(brushed_df)[

R/tm_g_scatterplotmatrix.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ srv_g_scatterplotmatrix <- function(id,
392392

393393
# create plot
394394
teal.reporter::teal_card(qenv) <- append(teal.reporter::teal_card(qenv), "## Plot")
395-
395+
396396
if (add_cor) {
397397
shinyjs::show("cor_method")
398398
shinyjs::show("cor_use")

R/tm_missing_data.R

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)