Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- ready_for_review
branches:
- main
- redesign_extraction@main
push:
branches:
- main
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ S3method(tm_g_scatterplot,default)
S3method(tm_g_scatterplot,picks)
S3method(tm_g_scatterplotmatrix,default)
S3method(tm_g_scatterplotmatrix,picks)
S3method(tm_outliers,data_extract_spec)
S3method(tm_outliers,list)
Comment thread
llrs-roche marked this conversation as resolved.
Outdated
S3method(tm_outliers,picks)
S3method(tm_t_crosstable,default)
S3method(tm_t_crosstable,picks)
S3method(tools::toHTML,markdown_internal)
Expand Down
154 changes: 47 additions & 107 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,91 +53,21 @@
#'
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
#' CO2 <- CO2
#' CO2[["primary_key"]] <- seq_len(nrow(CO2))
#' })
#' join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key"))
#'
#' vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")))
#'
#' app <- init(
#' data = data,
#' modules = modules(
#' tm_outliers(
#' outlier_var = list(
#' data_extract_spec(
#' dataname = "CO2",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
#' selected = "uptake",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' )
#' ),
#' categorical_var = list(
#' data_extract_spec(
#' dataname = "CO2",
#' filter = filter_spec(
#' vars = vars,
#' choices = value_choices(data[["CO2"]], vars$selected),
#' selected = value_choices(data[["CO2"]], vars$selected),
#' multiple = TRUE
#' )
#' )
#' )
#' )
#' )
#' )
#' if (interactive()) {
#' shinyApp(app$ui, app$server)
#' }
#'
#' @examplesShinylive
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examples
#'
#' # CDISC data example
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- teal.data::rADSL
#' })
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor)))
#' vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl))
#'
#' data <- within(data, CO2 <- CO2)
#'
#' app <- init(
#' data = data,
#' modules = modules(
#' tm_outliers(
#' outlier_var = list(
#' data_extract_spec(
#' dataname = "ADSL",
#' select = select_spec(
#' label = "Select variable:",
#' choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
#' selected = "AGE",
#' multiple = FALSE,
#' fixed = FALSE
#' )
#' )
#' outlier_var = teal.picks::picks(
#' datasets("CO2", "CO2"),
#' teal.picks::variables(c("conc", "uptake"), "uptake"),
#' teal.picks::values()
#' ),
#' categorical_var = list(
#' data_extract_spec(
#' dataname = "ADSL",
#' filter = filter_spec(
#' vars = vars,
#' choices = value_choices(data[["ADSL"]], vars$selected),
#' selected = value_choices(data[["ADSL"]], vars$selected),
#' multiple = TRUE
#' )
#' )
#' categorical_var = teal.picks::picks(
#' datasets("CO2", "CO2"),
#' teal.picks::variables(c("Plant", "Type", "Treatment"), "Plant"),
#' teal.picks::values()
#' )
#' )
#' )
Expand All @@ -159,37 +89,17 @@
#' })
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor)))
#' vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl))
#'
#'
#' app <- init(
#' data = data,
#' modules = modules(
#' tm_outliers(
#' outlier_var = list(
#' teal.picks::picks(
#' datasets("ADSL"),
#' teal.picks::variables(
#' choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
#' selected = "AGE",
#' multiple = FALSE,
#' fixed = FALSE
#' ),
#' teal.picks::values()
#' )
#' outlier_var = teal.picks::picks(
#' datasets("ADSL", "ADSL"),
#' teal.picks::variables(c("AGE", "BMRKR1"), "AGE")
#' ),
#' categorical_var = list(
#' teal.picks::picks(
#' datasets("ADSL"),
#' teal.picks::variables(),
#' values(
#' vars = vars,
#' choices = value_choices(data[["ADSL"]], vars$selected),
#' selected = value_choices(data[["ADSL"]], vars$selected),
#' multiple = TRUE
#' )
#' )
#' categorical_var = teal.picks::picks(
#' datasets("ADSL", "ADSL"),
#' teal.picks::variables(teal.picks::is_categorical(min.len = 1, max.len = 10))
#' )
#' )
#' )
Expand All @@ -201,8 +111,18 @@
#' @export
#'
tm_outliers <- function(label = "Outliers Module",
outlier_var,
categorical_var = NULL,
outlier_var = teal.picks::picks(
teal.picks::datasets(),
teal.picks::variables(is.numeric, 1L, multiple = FALSE)
),
categorical_var = teal.picks::picks(
teal.picks::datasets(),
teal.picks::variables(
choices = teal.picks::is_categorical(min.len = 1, max.len = 10),
selected = 1L,
multiple = TRUE
)
),
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
plot_height = c(600, 200, 2000),
Expand All @@ -211,6 +131,23 @@ tm_outliers <- function(label = "Outliers Module",
post_output = NULL,
transformators = list(),
decorators = list()) {
UseMethod("tm_outliers", outlier_var)
}

#' @export
tm_outliers.data_extract_spec <- function(label = "Outliers Module",
outlier_var,
categorical_var = NULL,
ggtheme = c(
"gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"
),
ggplot2_args = teal.widgets::ggplot2_args(),
plot_height = c(600, 200, 2000),
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()) {
message("Initializing tm_outliers")

# Normalize the parameters
Expand Down Expand Up @@ -279,6 +216,9 @@ tm_outliers <- function(label = "Outliers Module",
ans
}

#' @export
tm_outliers.list <- tm_outliers.data_extract_spec

# UI function for the outliers module
ui_outliers <- function(id, ...) {
args <- list(...)
Expand Down
Loading
Loading