Skip to content

Commit

Permalink
Merge branch 'main' into 712-tm_a_pca@main
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo authored Apr 22, 2024
2 parents 7099007 + 9e5c0aa commit aa9d18c
Show file tree
Hide file tree
Showing 9 changed files with 821 additions and 172 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: teal.modules.general
Title: General Modules for 'teal' Applications
Version: 0.3.0.9017
Version: 0.3.0.9021
Date: 2024-04-19
Authors@R: c(
person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal.modules.general 0.3.0.9017
# teal.modules.general 0.3.0.9021

# teal.modules.general 0.3.0

Expand Down
168 changes: 84 additions & 84 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,49 @@
#' CO2 <- data.frame(CO2)
#' })
#' datanames(data) <- c("CO2")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' app <- init(
#' data = data,
#' modules = modules(
#' tm_g_bivariate(
#' x = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "conc",
#' fixed = FALSE
#' )
#' ),
#' y = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "uptake",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' ),
#' row_facet = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "Type",
#' fixed = FALSE
#' )
#' ),
#' col_facet = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "Treatment",
#' fixed = FALSE
#' )
#' ),
#' ggplot2_args = ggplot2_args(
#' labs = list(subtitle = "Plot generated by Bivariate Module")
#' modules = tm_g_bivariate(
#' x = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "conc",
#' fixed = FALSE
#' )
#' ),
#' y = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "uptake",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' ),
#' row_facet = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "Type",
#' fixed = FALSE
#' )
#' ),
#' col_facet = data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]]),
#' selected = "Treatment",
#' fixed = FALSE
#' )
#' ),
#' ggplot2_args = ggplot2_args(
#' labs = list(subtitle = "Plot generated by Bivariate Module")
#' )
#' )
#' )
Expand All @@ -121,48 +118,46 @@
#'
#' app <- init(
#' data = data,
#' modules = modules(
#' tm_g_bivariate(
#' x = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "AGE",
#' fixed = FALSE
#' )
#' ),
#' y = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "SEX",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' ),
#' row_facet = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "ARM",
#' fixed = FALSE
#' )
#' ),
#' col_facet = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "COUNTRY",
#' fixed = FALSE
#' )
#' ),
#' ggplot2_args = ggplot2_args(
#' labs = list(subtitle = "Plot generated by Bivariate Module")
#' modules = tm_g_bivariate(
#' x = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "AGE",
#' fixed = FALSE
#' )
#' ),
#' y = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "SEX",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' ),
#' row_facet = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "ARM",
#' fixed = FALSE
#' )
#' ),
#' col_facet = data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]]),
#' selected = "COUNTRY",
#' fixed = FALSE
#' )
#' ),
#' ggplot2_args = ggplot2_args(
#' labs = list(subtitle = "Plot generated by Bivariate Module")
#' )
#' )
#' )
Expand Down Expand Up @@ -666,7 +661,12 @@ srv_g_bivariate <- function(id,
expr = {
# Add facetting labels
# optional: grid.newpage() # nolint: commented_code.
p <- add_facet_labels(p, xfacet_label = nulled_col_facet_name, yfacet_label = nulled_row_facet_name)
# Prefixed with teal.modules.general as its usage will appear in "Show R code"
p <- teal.modules.general::add_facet_labels(
p,
xfacet_label = nulled_col_facet_name,
yfacet_label = nulled_row_facet_name
)
grid::grid.newpage()
grid::grid.draw(p)
},
Expand Down
18 changes: 15 additions & 3 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,11 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
values = c("grey90", c(getOption("ggplot2.discrete.colour")[2], "#ff2951ff")[1]),
labels = c("Present", "Missing")
) +
scale_y_continuous(labels = scales::percent_format(), breaks = seq(0, 1, by = 0.1), expand = c(0, 0)) +
scale_y_continuous(
labels = scales::percent_format(),
breaks = seq(0, 1, by = 0.1),
expand = c(0, 0)
) +
geom_text(
aes(label = ifelse(isna == TRUE, sprintf("%d [%.02f%%]", n, n_pct), ""), y = 1),
hjust = 1,
Expand Down Expand Up @@ -803,7 +807,11 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
fill = ~isna
) +
geom_bar(alpha = 1, stat = "identity", position = "fill") +
scale_y_continuous(labels = scales::percent_format(), breaks = seq(0, 1, by = 0.1), expand = c(0, 0)) +
scale_y_continuous(
labels = scales::percent_format(),
breaks = seq(0, 1, by = 0.1),
expand = c(0, 0)
) +
scale_fill_manual(
name = "",
values = c("grey90", c(getOption("ggplot2.discrete.colour")[2], "#ff2951ff")[1]),
Expand Down Expand Up @@ -972,7 +980,11 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par
dplyr::distinct() %>%
ggplot(aes(x = id, y = n)) +
geom_bar(stat = "identity", fill = c(getOption("ggplot2.discrete.colour")[2], "#ff2951ff")[1]) +
geom_text(aes(label = n), position = position_dodge(width = 0.9), vjust = -0.25) +
geom_text(
aes(label = n),
position = position_dodge(width = 0.9),
vjust = -0.25
) +
ylim(c(0, max(data_combination_plot_cutoff$n) * 1.5)) +
labs1 +
ggthemes1 +
Expand Down
Loading

0 comments on commit aa9d18c

Please sign in to comment.