Skip to content

Commit

Permalink
198 Include user's card labels when generating the report (#584)
Browse files Browse the repository at this point in the history
this PR fixes
#583

this is follow-up after
insightsengineering/teal.reporter#219

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kartikeyakirar and github-actions[bot] authored Oct 13, 2023
1 parent ecca50b commit b840906
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
indentation_linter = NULL
)
13 changes: 7 additions & 6 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -999,12 +999,13 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("PCA Plot")
card$append_text("PCA Plot", "header2")
card$append_text("Principal Component Analysis Plot", "header3")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Principal Component Analysis Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Principal Components Table", "header3")
card$append_table(computation()[["tbl_importance"]])
card$append_text("Eigenvectors Table", "header3")
Expand Down
12 changes: 7 additions & 5 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,13 @@ srv_a_regression <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Linear Regression Plot")
card$append_text("Linear Regression Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Linear Regression Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,13 @@ srv_tm_g_association <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Association Plot")
card$append_text("Association Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Association Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,13 @@ srv_g_bivariate <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Bivariate Plot")
card$append_text("Bivariate Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Bivariate Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -1225,11 +1225,13 @@ srv_distribution <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Distribution Plot")
card$append_text("Distribution Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Distribution Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
if (input$tabs == "Histogram") {
card$append_plot(dist_r(), dim = pws1$dim())
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,13 @@ srv_g_response <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Response Plot")
card$append_text("Response Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Response Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,13 @@ srv_g_scatterplot <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Scatter Plot")
card$append_text("Scatter Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Scatter Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ srv_g_scatterplotmatrix <- function(id, data, reporter, filter_panel_api, variab

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Scatter Plot Matrix")
card$append_text("Scatter Plot Matrix", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Scatter Plot Matrix",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down
9 changes: 7 additions & 2 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -1200,12 +1200,17 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card_fun <- function(comment, label) {
card <- teal::TealReportCard$new()
sum_type <- input$summary_type
title <- if (sum_type == "By Variable Levels") paste0(sum_type, " Table") else paste0(sum_type, " Plot")
title_dataname <- paste(title, dataname, sep = " - ")
card$set_name(paste("Missing Data", sum_type, dataname, sep = " - "))
label <- if (label == "") {
paste("Missing Data", sum_type, dataname, sep = " - ")
} else {
label
}
card$set_name(label)
card$append_text(title_dataname, "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
if (sum_type == "Summary") {
Expand Down
13 changes: 7 additions & 6 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1146,13 +1146,14 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card_fun <- function(comment, label) {
tab_type <- input$tabs
card$set_name(paste0("Outliers - ", tab_type))
card$append_text(tab_type, "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())

card <- teal::report_card_template(
title = paste0("Outliers - ", tab_type),
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
categorical_var <- as.vector(merged$anl_input_r()$columns_source$categorical_var)
if (length(categorical_var) > 0) {
summary_table <- common_code_q()[["summary_table"]]
Expand Down
12 changes: 7 additions & 5 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Cross Table")
card$append_text("Cross Table", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Cross Table",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Table", "header3")
card$append_table(table_r())
if (!comment == "") {
Expand Down
12 changes: 7 additions & 5 deletions R/tm_variable_browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,13 @@ srv_variable_browser <- function(id,

### REPORTER
if (with_reporter) {
card_fun <- function(comment) {
card <- teal::TealReportCard$new()
card$set_name("Variable Browser Plot")
card$append_text("Variable Browser Plot", "header2")
if (with_filter) card$append_fs(filter_panel_api$get_filter_state())
card_fun <- function(comment, label) {
card <- teal::report_card_template(
title = "Variable Browser Plot",
label = label,
with_filter = with_filter,
filter_panel_api = filter_panel_api
)
card$append_text("Plot", "header3")
card$append_plot(variable_plot_r(), dim = pws$dim())
if (!comment == "") {
Expand Down

0 comments on commit b840906

Please sign in to comment.