diff --git a/R/FilterState-utils.R b/R/FilterState-utils.R index 539261819..07d75e496 100644 --- a/R/FilterState-utils.R +++ b/R/FilterState-utils.R @@ -21,42 +21,6 @@ #' - `"list"` `varname` in the condition call will be returned as `$` #' - `"matrix"` `varname` in the condition call will be returned as `[, ]` #' -#' @examples -#' # use non-exported function from teal.slice -#' init_filter_state <- getFromNamespace("init_filter_state", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- init_filter_state( -#' x = c(1:10, NA, Inf), -#' x_reactive = reactive(c(1:10, NA, Inf)), -#' slice = teal_slice( -#' varname = "varname", -#' dataname = "dataname" -#' ), -#' extract_type = "matrix" -#' ) -#' -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' -#' ui <- fluidPage( -#' filter_state$ui(id = "app"), -#' verbatimTextOutput("call") -#' ) -#' server <- function(input, output, session) { -#' filter_state$server("app") -#' -#' output$call <- renderText( -#' deparse1(filter_state$get_call(), collapse = "\n") -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @return `FilterState` object #' @keywords internal init_filter_state <- function(x, @@ -244,12 +208,6 @@ init_filter_state_expr <- function(slice) { #' #' @return Named `character(1)` containing a hexadecimal color representation. #' -#' @examples -#' fetch_bs_color <- getFromNamespace("fetch_bs_color", "teal.slice") -#' fetch_bs_color("primary") -#' fetch_bs_color("danger", 0.35) -#' fetch_bs_color("danger", "80") -#' #' @keywords internal #' fetch_bs_color <- function(color, alpha = NULL) { diff --git a/R/FilterStateChoices.R b/R/FilterStateChoices.R index 5ac4ca7fc..c1563cea6 100644 --- a/R/FilterStateChoices.R +++ b/R/FilterStateChoices.R @@ -7,109 +7,6 @@ #' #' @description Manages choosing elements from a set. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' ChoicesFilterState <- getFromNamespace("ChoicesFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- ChoicesFilterState$new( -#' x = c(LETTERS, NA), -#' slice = teal_slice(varname = "var", dataname = "data") -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state( -#' teal_slice( -#' dataname = "data", -#' varname = "var", -#' selected = "A", -#' keep_na = TRUE -#' ) -#' ) -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' library(shinyjs) -#' -#' data_choices <- c(sample(letters[1:4], 100, replace = TRUE), NA) -#' attr(data_choices, "label") <- "lowercase letters" -#' fs <- ChoicesFilterState$new( -#' x = data_choices, -#' slice = teal_slice( -#' dataname = "data", varname = "variable", selected = c("a", "c"), keep_na = TRUE -#' ) -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("ChoicesFilterState"), -#' fs$ui("fs") -#' )), -#' column(4, div( -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_choices"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_choices"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_choices"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_choices", "set drop NA", width = "100%"), br(), -#' actionButton("button2_choices", "set keep NA", width = "100%"), br(), -#' actionButton("button3_choices", "set selection: a, b", width = "100%"), br(), -#' actionButton("button4_choices", "deselect all", width = "100%"), br(), -#' actionButton("button0_choices", "set initial state", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' fs$server("fs") -#' output$condition_choices <- renderPrint(fs$get_call()) -#' output$formatted_choices <- renderText(fs$format()) -#' output$unformatted_choices <- renderPrint(fs$get_state()) -#' # modify filter state programmatically -#' observeEvent( -#' input$button1_choices, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "variable", keep_na = FALSE) -#' ) -#' ) -#' observeEvent( -#' input$button2_choices, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "variable", keep_na = TRUE) -#' ) -#' ) -#' observeEvent( -#' input$button3_choices, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "variable", selected = c("a", "b")) -#' ) -#' ) -#' observeEvent( -#' input$button4_choices, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "variable", selected = character(0), keep_na = TRUE) -#' ) -#' ) -#' observeEvent( -#' input$button0_choices, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "variable", selected = c("a", "c"), keep_na = TRUE) -#' ) -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' ChoicesFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStateDate.R b/R/FilterStateDate.R index 05e9b7b93..e891d5d29 100644 --- a/R/FilterStateDate.R +++ b/R/FilterStateDate.R @@ -7,103 +7,6 @@ #' #' @description Manages choosing a range of `Date`s. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' DateFilterState <- getFromNamespace("DateFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- DateFilterState$new( -#' x = c(Sys.Date() + seq(1:10), NA), -#' slice = teal_slice(varname = "x", dataname = "data"), -#' extract_type = character(0) -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state( -#' teal_slice( -#' dataname = "data", -#' varname = "x", -#' selected = c(Sys.Date() + 3L, Sys.Date() + 8L), -#' keep_na = TRUE -#' ) -#' ) -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' library(shinyjs) -#' -#' dates <- c(Sys.Date() - 100, Sys.Date()) -#' data_date <- c(seq(from = dates[1], to = dates[2], length.out = 100), NA) -#' fs <- DateFilterState$new( -#' x = data_date, -#' slice = teal_slice( -#' dataname = "data", varname = "x", selected = data_date[c(47, 98)], keep_na = TRUE -#' ) -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("DateFilterState"), -#' fs$ui("fs") -#' )), -#' column(4, div( -#' id = "outputs", # div id is needed for toggling the element -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_date"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_date"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_date"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_date", "set drop NA", width = "100%"), br(), -#' actionButton("button2_date", "set keep NA", width = "100%"), br(), -#' actionButton("button3_date", "set a range", width = "100%"), br(), -#' actionButton("button4_date", "set full range", width = "100%"), br(), -#' actionButton("button0_date", "set initial state", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' fs$server("fs") -#' output$condition_date <- renderPrint(fs$get_call()) -#' output$formatted_date <- renderText(fs$format()) -#' output$unformatted_date <- renderPrint(fs$get_state()) -#' # modify filter state programmatically -#' observeEvent( -#' input$button1_date, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) -#' ) -#' observeEvent( -#' input$button2_date, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -#' ) -#' observeEvent( -#' input$button3_date, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", selected = data_date[c(34, 56)])) -#' ) -#' observeEvent( -#' input$button4_date, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", selected = dates)) -#' ) -#' observeEvent( -#' input$button0_date, -#' fs$set_state( -#' teal_slice("data", "variable", selected = data_date[c(47, 98)], keep_na = TRUE) -#' ) -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' DateFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStateDatettime.R b/R/FilterStateDatettime.R index eb29379d2..b688a0561 100644 --- a/R/FilterStateDatettime.R +++ b/R/FilterStateDatettime.R @@ -7,109 +7,6 @@ #' #' @description Manages choosing a range of date-times. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' DatetimeFilterState <- getFromNamespace("DatetimeFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- DatetimeFilterState$new( -#' x = c(Sys.time() + seq(0, by = 3600, length.out = 10), NA), -#' slice = teal_slice(varname = "x", dataname = "data"), -#' extract_type = character(0) -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state( -#' teal_slice( -#' dataname = "data", -#' varname = "x", -#' selected = c(Sys.time() + 3L, Sys.time() + 8L), -#' keep_na = TRUE -#' ) -#' ) -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' library(shinyjs) -#' -#' datetimes <- as.POSIXct(c("2012-01-01 12:00:00", "2020-01-01 12:00:00")) -#' data_datetime <- c(seq(from = datetimes[1], to = datetimes[2], length.out = 100), NA) -#' fs <- DatetimeFilterState$new( -#' x = data_datetime, -#' slice = teal_slice( -#' varname = "x", dataname = "data", selected = data_datetime[c(47, 98)], keep_na = TRUE -#' ) -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("DatetimeFilterState"), -#' fs$ui("fs") -#' )), -#' column(4, div( -#' id = "outputs", # div id is needed for toggling the element -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_datetime"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_datetime"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_datetime"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_datetime", "set drop NA", width = "100%"), br(), -#' actionButton("button2_datetime", "set keep NA", width = "100%"), br(), -#' actionButton("button3_datetime", "set a range", width = "100%"), br(), -#' actionButton("button4_datetime", "set full range", width = "100%"), br(), -#' actionButton("button0_datetime", "set initial state", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' fs$server("fs") -#' output$condition_datetime <- renderPrint(fs$get_call()) -#' output$formatted_datetime <- renderText(fs$format()) -#' output$unformatted_datetime <- renderPrint(fs$get_state()) -#' # modify filter state programmatically -#' observeEvent( -#' input$button1_datetime, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) -#' ) -#' observeEvent( -#' input$button2_datetime, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -#' ) -#' observeEvent( -#' input$button3_datetime, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "x", selected = data_datetime[c(34, 56)]) -#' ) -#' ) -#' observeEvent( -#' input$button4_datetime, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "x", selected = datetimes) -#' ) -#' ) -#' observeEvent( -#' input$button0_datetime, -#' fs$set_state( -#' teal_slice( -#' dataname = "data", varname = "x", selected = data_datetime[c(47, 98)], keep_na = TRUE -#' ) -#' ) -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' DatetimeFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStateEmpty.R b/R/FilterStateEmpty.R index e7d7118dd..1eb49f7e6 100644 --- a/R/FilterStateEmpty.R +++ b/R/FilterStateEmpty.R @@ -7,22 +7,6 @@ #' #' @description `FilterState` subclass representing an empty variable. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' EmptyFilterState <- getFromNamespace("EmptyFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- EmptyFilterState$new( -#' x = NA, -#' slice = teal_slice(varname = "x", dataname = "data"), -#' extract_type = character(0) -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -#' isolate(filter_state$get_call()) -#' #' @keywords internal #' EmptyFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStateExpr.R b/R/FilterStateExpr.R index d591ce5b1..262451605 100644 --- a/R/FilterStateExpr.R +++ b/R/FilterStateExpr.R @@ -12,55 +12,6 @@ #' The condition call is independent of the data #' and the filter card allows no interaction (the filter is always fixed). #' -#' @examples -#' # use non-exported function from teal.slice -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' FilterStateExpr <- getFromNamespace("FilterStateExpr", "teal.slice") -#' -#' filter_state <- FilterStateExpr$new( -#' slice = teal_slice( -#' dataname = "x", -#' id = "FA", -#' title = "Adult females", -#' expr = "sex == 'F' & age >= 18" -#' ) -#' ) -#' filter_state$get_call() -#' -#' # working filter in an app -#' library(shiny) -#' library(shinyjs) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("ChoicesFilterState"), -#' filter_state$ui("fs") -#' )), -#' column(8, div( -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_choices"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_choices"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_choices"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' filter_state$server("fs") -#' output$condition_choices <- renderPrint(filter_state$get_call()) -#' output$formatted_choices <- renderText(filter_state$format()) -#' output$unformatted_choices <- renderPrint(filter_state$get_state()) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' FilterStateExpr <- R6::R6Class( # nolint diff --git a/R/FilterStateLogical.R b/R/FilterStateLogical.R index 00bd9be26..e0bb84557 100644 --- a/R/FilterStateLogical.R +++ b/R/FilterStateLogical.R @@ -7,89 +7,6 @@ #' #' @description Manages choosing a logical state. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' LogicalFilterState <- getFromNamespace("LogicalFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- LogicalFilterState$new( -#' x = sample(c(TRUE, FALSE, NA), 10, replace = TRUE), -#' slice = teal_slice(varname = "x", dataname = "data") -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state( -#' teal_slice(dataname = "data", varname = "x", selected = TRUE, keep_na = TRUE) -#' ) -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' library(shinyjs) -#' -#' data_logical <- c(sample(c(TRUE, FALSE), 10, replace = TRUE), NA) -#' fs <- LogicalFilterState$new( -#' x = data_logical, -#' slice = teal_slice(dataname = "data", varname = "x", selected = FALSE, keep_na = TRUE) -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("LogicalFilterState"), -#' fs$ui("fs") -#' )), -#' column(4, div( -#' id = "outputs", # div id is needed for toggling the element -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_logical"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_logical"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_logical"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_logical", "set drop NA", width = "100%"), br(), -#' actionButton("button2_logical", "set keep NA", width = "100%"), br(), -#' actionButton("button3_logical", "set a selection", width = "100%"), br(), -#' actionButton("button0_logical", "set initial state", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' fs$server("fs") -#' output$condition_logical <- renderPrint(fs$get_call()) -#' output$formatted_logical <- renderText(fs$format()) -#' output$unformatted_logical <- renderPrint(fs$get_state()) -#' # modify filter state programmatically -#' observeEvent( -#' input$button1_logical, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) -#' ) -#' observeEvent( -#' input$button2_logical, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -#' ) -#' observeEvent( -#' input$button3_logical, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", selected = TRUE)) -#' ) -#' observeEvent( -#' input$button0_logical, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "x", selected = FALSE, keep_na = TRUE) -#' ) -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' LogicalFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStateRange.R b/R/FilterStateRange.R index 456917e06..5da4e1ee7 100644 --- a/R/FilterStateRange.R +++ b/R/FilterStateRange.R @@ -7,117 +7,6 @@ #' #' @description Manages choosing a numeric range. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' RangeFilterState <- getFromNamespace("RangeFilterState", "teal.slice") -#' -#' library(shiny) -#' -#' filter_state <- RangeFilterState$new( -#' x = c(NA, Inf, seq(1:10)), -#' slice = teal_slice(varname = "x", dataname = "data") -#' ) -#' isolate(filter_state$get_call()) -#' filter_state$set_state( -#' teal_slice( -#' dataname = "data", -#' varname = "x", -#' selected = c(3L, 8L), -#' keep_na = TRUE, -#' keep_inf = TRUE -#' ) -#' ) -#' isolate(filter_state$get_call()) -#' -#' # working filter in an app -#' library(shinyjs) -#' -#' data_range <- c(runif(100, 0, 1), NA, Inf) -#' fs <- RangeFilterState$new( -#' x = data_range, -#' slice = teal_slice( -#' dataname = "data", -#' varname = "x", -#' selected = c(0.15, 0.93), -#' keep_na = TRUE, -#' keep_inf = TRUE -#' ) -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("RangeFilterState"), -#' fs$ui("fs") -#' )), -#' column(4, div( -#' id = "outputs", # div id is needed for toggling the element -#' h4("Condition (i.e. call)"), # display the condition call generated by this FilterState -#' textOutput("condition_range"), br(), -#' h4("Unformatted state"), # display raw filter state -#' textOutput("unformatted_range"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_range"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_range", "set drop NA", width = "100%"), br(), -#' actionButton("button2_range", "set keep NA", width = "100%"), br(), -#' actionButton("button3_range", "set drop Inf", width = "100%"), br(), -#' actionButton("button4_range", "set keep Inf", width = "100%"), br(), -#' actionButton("button5_range", "set a range", width = "100%"), br(), -#' actionButton("button6_range", "set full range", width = "100%"), br(), -#' actionButton("button0_range", "set initial state", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' fs$server("fs") -#' output$condition_range <- renderPrint(fs$get_call()) -#' output$formatted_range <- renderText(fs$format()) -#' output$unformatted_range <- renderPrint(fs$get_state()) -#' # modify filter state programmatically -#' observeEvent( -#' input$button1_range, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) -#' ) -#' observeEvent( -#' input$button2_range, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -#' ) -#' observeEvent( -#' input$button3_range, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_inf = FALSE)) -#' ) -#' observeEvent( -#' input$button4_range, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", keep_inf = TRUE)) -#' ) -#' observeEvent( -#' input$button5_range, -#' fs$set_state( -#' teal_slice(dataname = "data", varname = "x", selected = c(0.2, 0.74)) -#' ) -#' ) -#' observeEvent( -#' input$button6_range, -#' fs$set_state(teal_slice(dataname = "data", varname = "x", selected = c(0, 1))) -#' ) -#' observeEvent( -#' input$button0_range, -#' fs$set_state( -#' teal_slice("data", "variable", selected = c(0.15, 0.93), keep_na = TRUE, keep_inf = TRUE) -#' ) -#' ) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } #' @keywords internal #' RangeFilterState <- R6::R6Class( # nolint diff --git a/R/FilterStates-utils.R b/R/FilterStates-utils.R index 4ac58dbbc..868bb859d 100644 --- a/R/FilterStates-utils.R +++ b/R/FilterStates-utils.R @@ -18,42 +18,6 @@ #' @return Object of class `FilterStates`. #' #' @keywords internal -#' @examples -#' # use non-exported function from teal.slice -#' init_filter_states <- getFromNamespace("init_filter_states", "teal.slice") -#' -#' df <- data.frame( -#' character = letters, -#' numeric = seq_along(letters), -#' date = seq(Sys.Date(), length.out = length(letters), by = "1 day"), -#' datetime = seq(Sys.time(), length.out = length(letters), by = "33.33 hours") -#' ) -#' rf <- init_filter_states( -#' data = df, -#' dataname = "DF" -#' ) -#' -#' library(shiny) -#' ui <- fluidPage( -#' actionButton("clear", span(icon("xmark"), "Remove all filters")), -#' rf$ui_add(id = "add"), -#' rf$ui_active("states"), -#' verbatimTextOutput("expr"), -#' ) -#' -#' server <- function(input, output, session) { -#' rf$srv_add(id = "add") -#' rf$srv_active(id = "states") -#' output$expr <- renderText({ -#' deparse1(rf$get_call(), collapse = "\n") -#' }) -#' observeEvent(input$clear, rf$clear_filter_states()) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @export #' init_filter_states <- function(data, @@ -141,18 +105,7 @@ init_filter_states.SummarizedExperiment <- function(data, # nolint #' @param data #' the `R` object containing elements which class can be checked through `vapply` or `apply`. #' @return `character` vector of variable names. -#' @examples -#' # use non-exported function from teal.slice -#' get_supported_filter_varnames <- getFromNamespace("get_supported_filter_varnames", "teal.slice") #' -#' df <- data.frame( -#' a = letters[1:3], -#' b = 1:3, -#' c = Sys.Date() + 1:3, -#' d = Sys.time() + 1:3, -#' z = complex(3) -#' ) -#' get_supported_filter_varnames(df) #' @keywords internal #' @export get_supported_filter_varnames <- function(data) { diff --git a/R/FilterStatesDF.R b/R/FilterStatesDF.R index ba4579651..4d6bd0738 100644 --- a/R/FilterStatesDF.R +++ b/R/FilterStatesDF.R @@ -7,148 +7,6 @@ #' #' @description Handles filter states in a `data.frame`. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' init_filter_states <- getFromNamespace("init_filter_states", "teal.slice") -#' -#' library(shiny) -#' library(shinyjs) -#' -#' # create data frame to filter -#' data_df <- data.frame( -#' NUM1 = 1:100, -#' NUM2 = round(runif(100, min = 20, max = 23)), -#' CHAR1 = sample(LETTERS[1:6], size = 100, replace = TRUE), -#' CHAR2 = sample(c("M", "F"), size = 100, replace = TRUE), -#' DATE = seq(as.Date("2020-01-01"), by = 1, length.out = 100), -#' DATETIME = as.POSIXct(seq(as.Date("2020-01-01"), by = 1, length.out = 100)) -#' ) -#' data_na <- data.frame( -#' NUM1 = NA, -#' NUM2 = NA, -#' CHAR1 = NA, -#' CHAR2 = NA, -#' DATE = NA, -#' DATETIME = NA -#' ) -#' data_df <- rbind(data_df, data_na) -#' -#' # initiate `FilterStates` object -#' filter_states_df <- init_filter_states( -#' data = data_df, -#' dataname = "dataset", -#' datalabel = ("label") -#' ) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' include_css_files(pattern = "filter-panel"), -#' include_js_files(pattern = "count-bar-labels"), -#' column(4, div( -#' h4("Active filters"), -#' filter_states_df$ui_active("fsdf") -#' )), -#' column(4, div( -#' h4("Manual filter control"), -#' filter_states_df$ui_add("add_filters"), br(), -#' h4("Condition (i.e. call)"), # display the subset expression generated by this FilterStates -#' textOutput("call_df"), br(), -#' h4("Formatted state"), # display human readable filter state -#' textOutput("formatted_df"), br() -#' )), -#' column(4, div( -#' h4("Programmatic filter control"), -#' actionButton("button1_df", "set NUM1 < 30", width = "100%"), br(), -#' actionButton("button2_df", "set NUM2 %in% c(20, 21)", width = "100%"), br(), -#' actionButton("button3_df", "set CHAR1 %in% c(\"B\", \"C\", \"D\")", width = "100%"), br(), -#' actionButton("button4_df", "set CHAR2 == \"F\"", width = "100%"), br(), -#' actionButton("button5_df", "set DATE <= 2020-02-02", width = "100%"), br(), -#' actionButton("button6_df", "set DATETIME <= 2020-02-02", width = "100%"), br(), -#' hr(), -#' actionButton("button7_df", "remove NUM1", width = "100%"), br(), -#' actionButton("button8_df", "remove NUM2", width = "100%"), br(), -#' actionButton("button9_df", "remove CHAR1", width = "100%"), br(), -#' actionButton("button10_df", "remove CHAR2", width = "100%"), br(), -#' actionButton("button11_df", "remove DATE", width = "100%"), br(), -#' actionButton("button12_df", "remove DATETIME", width = "100%"), br(), -#' hr(), -#' actionButton("button0_df", "clear all filters", width = "100%"), br() -#' )) -#' ) -#' -#' server <- function(input, output, session) { -#' filter_states_df$srv_add("add_filters") -#' filter_states_df$srv_active("fsdf") -#' -#' output$call_df <- renderPrint(filter_states_df$get_call()) -#' output$formatted_df <- renderText(filter_states_df$format()) -#' -#' observeEvent(input$button1_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "NUM1", selected = c(0, 30))) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' observeEvent(input$button2_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "NUM2", selected = c(20, 21))) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' observeEvent(input$button3_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "CHAR1", selected = c("B", "C", "D"))) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' observeEvent(input$button4_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "CHAR2", selected = c("F"))) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' observeEvent(input$button5_df, { -#' filter_state <- teal_slices( -#' teal_slice("dataset", "DATE", selected = c("2020-01-01", "2020-02-02")) -#' ) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' observeEvent(input$button6_df, { -#' filter_state <- teal_slices( -#' teal_slice("dataset", "DATETIME", selected = as.POSIXct(c("2020-01-01", "2020-02-02"))) -#' ) -#' filter_states_df$set_filter_state(state = filter_state) -#' }) -#' -#' observeEvent(input$button7_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "NUM1")) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' observeEvent(input$button8_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "NUM2")) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' observeEvent(input$button9_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "CHAR1")) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' observeEvent(input$button10_df, { -#' filter_state <- teal_slices(teal_slice("dataset", "CHAR2")) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' observeEvent(input$button11_df, { -#' filter_state <- teal_slices( -#' teal_slice("dataset", "DATE") -#' ) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' observeEvent(input$button12_df, { -#' filter_state <- teal_slices( -#' teal_slice("dataset", "DATETIME", selected = as.POSIXct(c("2020-01-01", "2020-02-02"))) -#' ) -#' filter_states_df$remove_filter_state(filter_state) -#' }) -#' -#' observeEvent(input$button0_df, filter_states_df$clear_filter_states()) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } #' @keywords internal #' DFFilterStates <- R6::R6Class( # nolint diff --git a/R/FilteredData-utils.R b/R/FilteredData-utils.R index bb3212dad..9e324ef1f 100644 --- a/R/FilteredData-utils.R +++ b/R/FilteredData-utils.R @@ -83,58 +83,6 @@ eval_expr_with_msg <- function(expr, env) { #' #' @return `NULL`, invisibly. #' -#' @examples -#' # use non-exported function from teal.slice -#' toggle_icon <- getFromNamespace("toggle_icon", "teal.slice") -#' -#' library(shiny) -#' library(shinyjs) -#' -#' ui <- fluidPage( -#' useShinyjs(), -#' actionButton("hide_content", label = "hide", icon = icon("xmark")), -#' actionButton("show_content", label = "show", icon = icon("check")), -#' actionButton("toggle_content", label = "toggle", icon = icon("angle-down")), -#' br(), -#' div( -#' id = "content", -#' verbatimTextOutput("printout") -#' ) -#' ) -#' -#' server <- function(input, output, session) { -#' observeEvent(input$hide_content, -#' { -#' hide("content") -#' toggle_icon("toggle_content", c("fa-angle-down", "fa-angle-right"), one_way = TRUE) -#' }, -#' ignoreInit = TRUE -#' ) -#' -#' observeEvent(input$show_content, -#' { -#' show("content") -#' toggle_icon("toggle_content", c("fa-angle-right", "fa-angle-down"), one_way = TRUE) -#' }, -#' ignoreInit = TRUE -#' ) -#' -#' observeEvent(input$toggle_content, -#' { -#' toggle("content") -#' toggle_icon("toggle_content", c("fa-angle-right", "fa-angle-down")) -#' }, -#' ignoreInit = TRUE -#' ) -#' -#' output$printout <- renderPrint({ -#' head(faithful, 10) -#' }) -#' } -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @name toggle_button #' @rdname toggle_button #' @keywords internal @@ -190,13 +138,7 @@ toggle_title <- function(input_id, titles, one_way = FALSE) { } #' @inherit teal.data::topological_sort description details params title -#' @examples -#' # use non-exported function from teal.slice -#' topological_sort <- getFromNamespace("topological_sort", "teal.slice") #' -#' topological_sort(list(A = c(), B = c("A"), C = c("B"), D = c("A"))) -#' topological_sort(list(D = c("A"), A = c(), B = c("A"), C = c("B"))) -#' topological_sort(list(D = c("A"), B = c("A"), C = c("B"), A = c())) #' @keywords internal topological_sort <- function(graph) { utils::getFromNamespace("topological_sort", ns = "teal.data")(graph) diff --git a/R/FilteredData.R b/R/FilteredData.R index a88bf975d..d0d45da58 100644 --- a/R/FilteredData.R +++ b/R/FilteredData.R @@ -36,59 +36,6 @@ #' 2. `dataname`: the name of one of the datasets in this `FilteredData` object #' 3. `varname`: one of the columns in a dataset #' -#' @examples -#' # use non-exported function from teal.slice -#' FilteredData <- getFromNamespace("FilteredData", "teal.slice") -#' -#' library(shiny) -#' -#' datasets <- FilteredData$new(list(iris = iris, mtcars = mtcars)) -#' -#' # get datanames -#' datasets$datanames() -#' -#' datasets$set_filter_state( -#' teal_slices(teal_slice(dataname = "iris", varname = "Species", selected = "virginica")) -#' ) -#' isolate(datasets$get_call("iris")) -#' -#' datasets$set_filter_state( -#' teal_slices(teal_slice(dataname = "mtcars", varname = "mpg", selected = c(15, 20))) -#' ) -#' -#' isolate(datasets$get_filter_state()) -#' isolate(datasets$get_call("iris")) -#' isolate(datasets$get_call("mtcars")) -#' -#' @examplesIf requireNamespace("MultiAssayExperiment") -#' ### set_filter_state -#' library(shiny) -#' -#' data(miniACC, package = "MultiAssayExperiment") -#' datasets <- FilteredData$new(list(iris = iris, mae = miniACC)) -#' fs <- teal_slices( -#' teal_slice( -#' dataname = "iris", varname = "Sepal.Length", selected = c(5.1, 6.4), -#' keep_na = TRUE, keep_inf = FALSE -#' ), -#' teal_slice( -#' dataname = "iris", varname = "Species", selected = c("setosa", "versicolor"), -#' keep_na = FALSE -#' ), -#' teal_slice( -#' dataname = "mae", varname = "years_to_birth", selected = c(30, 50), -#' keep_na = TRUE, keep_inf = FALSE -#' ), -#' teal_slice(dataname = "mae", varname = "vital_status", selected = "1", keep_na = FALSE), -#' teal_slice(dataname = "mae", varname = "gender", selected = "female", keep_na = TRUE), -#' teal_slice( -#' dataname = "mae", varname = "ARRAY_TYPE", -#' selected = "", keep_na = TRUE, experiment = "RPPAArray", arg = "subset" -#' ) -#' ) -#' datasets$set_filter_state(state = fs) -#' isolate(datasets$get_filter_state()) -#' #' @keywords internal #' FilteredData <- R6::R6Class( # nolint diff --git a/R/FilteredDatasetDataframe.R b/R/FilteredDatasetDataframe.R index 7046b9e78..c0503afc0 100644 --- a/R/FilteredDatasetDataframe.R +++ b/R/FilteredDatasetDataframe.R @@ -4,31 +4,6 @@ #' @docType class #' @title The `DataframeFilteredDataset` `R6` class #' -#' @examples -#' # use non-exported function from teal.slice -#' DataframeFilteredDataset <- getFromNamespace("DataframeFilteredDataset", "teal.slice") -#' -#' library(shiny) -#' -#' ds <- DataframeFilteredDataset$new(iris, "iris") -#' ds$set_filter_state( -#' teal_slices( -#' teal_slice(dataname = "iris", varname = "Species", selected = "virginica"), -#' teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5)) -#' ) -#' ) -#' isolate(ds$get_filter_state()) -#' isolate(ds$get_call()) -#' -#' ## set_filter_state -#' dataset <- DataframeFilteredDataset$new(iris, "iris") -#' fs <- teal_slices( -#' teal_slice(dataname = "iris", varname = "Species", selected = "virginica"), -#' teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5)) -#' ) -#' dataset$set_filter_state(state = fs) -#' isolate(dataset$get_filter_state()) -#' #' @keywords internal #' DataframeFilteredDataset <- R6::R6Class( # nolint diff --git a/R/FilteredDatasetDefault.R b/R/FilteredDatasetDefault.R index c26ba8b07..a876ef730 100644 --- a/R/FilteredDatasetDefault.R +++ b/R/FilteredDatasetDefault.R @@ -6,16 +6,6 @@ #' #' @description Stores any object as inert entity. Filtering is not supported. #' -#' @examples -#' # use non-exported function from teal.slice -#' DefaultFilteredDataset <- getFromNamespace("DefaultFilteredDataset", "teal.slice") -#' -#' library(shiny) -#' -#' ds <- DefaultFilteredDataset$new(letters, "letters") -#' isolate(ds$get_filter_state()) -#' isolate(ds$get_call()) -#' #' @keywords internal #' DefaultFilteredDataset <- R6::R6Class( # nolint diff --git a/R/FilteredDatasetMAE.R b/R/FilteredDatasetMAE.R index 348e5e2f0..57ac23fc9 100644 --- a/R/FilteredDatasetMAE.R +++ b/R/FilteredDatasetMAE.R @@ -4,31 +4,6 @@ #' @docType class #' @title `MAEFilteredDataset` `R6` class #' -#' @examplesIf requireNamespace("MultiAssayExperiment") -#' # use non-exported function from teal.slice -#' MAEFilteredDataset <- getFromNamespace("MAEFilteredDataset", "teal.slice") -#' -#' data(miniACC, package = "MultiAssayExperiment") -#' dataset <- MAEFilteredDataset$new(miniACC, "MAE") -#' fs <- teal_slices( -#' teal_slice( -#' dataname = "MAE", varname = "years_to_birth", selected = c(30, 50), keep_na = TRUE -#' ), -#' teal_slice( -#' dataname = "MAE", varname = "vital_status", selected = "1", keep_na = FALSE -#' ), -#' teal_slice( -#' dataname = "MAE", varname = "gender", selected = "female", keep_na = TRUE -#' ), -#' teal_slice( -#' dataname = "MAE", varname = "ARRAY_TYPE", selected = "", keep_na = TRUE -#' ) -#' ) -#' dataset$set_filter_state(state = fs) -#' -#' library(shiny) -#' isolate(dataset$get_filter_state()) -#' #' @keywords internal #' MAEFilteredDataset <- R6::R6Class( # nolint diff --git a/R/calls_combine_by.R b/R/calls_combine_by.R index 81c9394fe..94823a3d1 100644 --- a/R/calls_combine_by.R +++ b/R/calls_combine_by.R @@ -13,17 +13,6 @@ #' @return #' A `call` where elements of `calls` are composed with `operator` or `NULL` if `calls` is an empty list. #' -#' @examples -#' # use non-exported function from teal.slice -#' calls_combine_by <- getFromNamespace("calls_combine_by", "teal.slice") -#' -#' calls <- list( -#' quote(SEX == "F"), # subsetting on factor -#' quote(AGE >= 20 & AGE <= 50), # subsetting on range -#' quote(!SURV) # subsetting on logical -#' ) -#' calls_combine_by(calls, "&") -#' #' @keywords internal #' calls_combine_by <- function(calls, operator) { diff --git a/R/count_labels.R b/R/count_labels.R index 6fc3d9a40..a23aff6f8 100644 --- a/R/count_labels.R +++ b/R/count_labels.R @@ -20,55 +20,6 @@ #' #' Each child element can have a unique `id` attribute to be used independently. #' -#' @examples -#' # use non-exported function from teal.slice -#' include_js_files <- getFromNamespace("include_js_files", "teal.slice") -#' include_css_files <- getFromNamespace("include_css_files", "teal.slice") -#' countBars <- getFromNamespace("countBars", "teal.slice") -#' updateCountBars <- getFromNamespace("updateCountBars", "teal.slice") -#' -#' library(shiny) -#' -#' choices <- sample(as.factor(c("a", "b", "c")), size = 20, replace = TRUE) -#' counts <- table(choices) -#' labels <- countBars( -#' inputId = "counts", -#' choices = c("a", "b", "c"), -#' countsmax = counts, -#' countsnow = unname(counts) -#' ) -#' -#' ui <- fluidPage( -#' div( -#' class = "choices_state", -#' include_js_files("count-bar-labels.js"), -#' include_css_files(pattern = "filter-panel"), -#' checkboxGroupInput( -#' inputId = "choices", -#' selected = levels(choices), -#' choiceNames = labels, -#' choiceValues = levels(choices), -#' label = NULL -#' ) -#' ) -#' ) -#' server <- function(input, output, session) { -#' observeEvent(input$choices, { -#' new_counts <- counts -#' new_counts[!names(new_counts) %in% input$choices] <- 0 -#' updateCountBars( -#' inputId = "counts", -#' choices = levels(choices), -#' countsmax = counts, -#' countsnow = unname(new_counts) -#' ) -#' }) -#' } -#' -#' if (interactive()) { -#' shinyApp(ui, server) -#' } -#' #' @keywords internal #' countBars <- function(inputId, choices, countsmax, countsnow = NULL) { # nolint diff --git a/R/utils.R b/R/utils.R index 6f70f89d1..fa47c157d 100644 --- a/R/utils.R +++ b/R/utils.R @@ -52,12 +52,6 @@ include_js_files <- function(pattern) { #' #' @return A `c` call. #' -#' @examples -#' # use non-exported function from teal.slice -#' make_c_call <- getFromNamespace("make_c_call", "teal.slice") -#' make_c_call(1:3) -#' make_c_call(1) -#' #' @keywords internal make_c_call <- function(choices) { if (length(choices) > 1) { diff --git a/R/variable_types.R b/R/variable_types.R index 2df1b5310..06ca93e5f 100644 --- a/R/variable_types.R +++ b/R/variable_types.R @@ -6,33 +6,6 @@ #' #' @return Character vector of classes of `columns` from provided `data`. #' -#' @examples -#' # use non-exported function from teal.slice -#' variable_types <- getFromNamespace("variable_types", "teal.slice") -#' -#' variable_types( -#' data.frame( -#' x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), -#' stringsAsFactors = FALSE -#' ), -#' "x" -#' ) -#' -#' variable_types( -#' data.frame( -#' x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), -#' stringsAsFactors = FALSE -#' ), -#' c("x", "z") -#' ) -#' -#' variable_types( -#' data.frame( -#' x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), -#' stringsAsFactors = FALSE -#' ) -#' ) -#' #' @keywords internal #' variable_types <- function(data, columns = NULL) { diff --git a/man/ChoicesFilterState.Rd b/man/ChoicesFilterState.Rd index cd804ca75..589dc928b 100644 --- a/man/ChoicesFilterState.Rd +++ b/man/ChoicesFilterState.Rd @@ -6,110 +6,6 @@ \title{\code{FilterState} object for categorical data} \description{ Manages choosing elements from a set. -} -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -ChoicesFilterState <- getFromNamespace("ChoicesFilterState", "teal.slice") - -library(shiny) - -filter_state <- ChoicesFilterState$new( - x = c(LETTERS, NA), - slice = teal_slice(varname = "var", dataname = "data") -) -isolate(filter_state$get_call()) -filter_state$set_state( - teal_slice( - dataname = "data", - varname = "var", - selected = "A", - keep_na = TRUE - ) -) -isolate(filter_state$get_call()) - -# working filter in an app -library(shinyjs) - -data_choices <- c(sample(letters[1:4], 100, replace = TRUE), NA) -attr(data_choices, "label") <- "lowercase letters" -fs <- ChoicesFilterState$new( - x = data_choices, - slice = teal_slice( - dataname = "data", varname = "variable", selected = c("a", "c"), keep_na = TRUE - ) -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("ChoicesFilterState"), - fs$ui("fs") - )), - column(4, div( - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_choices"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_choices"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_choices"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_choices", "set drop NA", width = "100\%"), br(), - actionButton("button2_choices", "set keep NA", width = "100\%"), br(), - actionButton("button3_choices", "set selection: a, b", width = "100\%"), br(), - actionButton("button4_choices", "deselect all", width = "100\%"), br(), - actionButton("button0_choices", "set initial state", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - fs$server("fs") - output$condition_choices <- renderPrint(fs$get_call()) - output$formatted_choices <- renderText(fs$format()) - output$unformatted_choices <- renderPrint(fs$get_state()) - # modify filter state programmatically - observeEvent( - input$button1_choices, - fs$set_state( - teal_slice(dataname = "data", varname = "variable", keep_na = FALSE) - ) - ) - observeEvent( - input$button2_choices, - fs$set_state( - teal_slice(dataname = "data", varname = "variable", keep_na = TRUE) - ) - ) - observeEvent( - input$button3_choices, - fs$set_state( - teal_slice(dataname = "data", varname = "variable", selected = c("a", "b")) - ) - ) - observeEvent( - input$button4_choices, - fs$set_state( - teal_slice(dataname = "data", varname = "variable", selected = character(0), keep_na = TRUE) - ) - ) - observeEvent( - input$button0_choices, - fs$set_state( - teal_slice(dataname = "data", varname = "variable", selected = c("a", "c"), keep_na = TRUE) - ) - ) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} \section{Super class}{ diff --git a/man/DFFilterStates.Rd b/man/DFFilterStates.Rd index 74d189bd1..94af62581 100644 --- a/man/DFFilterStates.Rd +++ b/man/DFFilterStates.Rd @@ -7,149 +7,6 @@ \description{ Handles filter states in a \code{data.frame}. } -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -init_filter_states <- getFromNamespace("init_filter_states", "teal.slice") - -library(shiny) -library(shinyjs) - -# create data frame to filter -data_df <- data.frame( - NUM1 = 1:100, - NUM2 = round(runif(100, min = 20, max = 23)), - CHAR1 = sample(LETTERS[1:6], size = 100, replace = TRUE), - CHAR2 = sample(c("M", "F"), size = 100, replace = TRUE), - DATE = seq(as.Date("2020-01-01"), by = 1, length.out = 100), - DATETIME = as.POSIXct(seq(as.Date("2020-01-01"), by = 1, length.out = 100)) -) -data_na <- data.frame( - NUM1 = NA, - NUM2 = NA, - CHAR1 = NA, - CHAR2 = NA, - DATE = NA, - DATETIME = NA -) -data_df <- rbind(data_df, data_na) - -# initiate `FilterStates` object -filter_states_df <- init_filter_states( - data = data_df, - dataname = "dataset", - datalabel = ("label") -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("Active filters"), - filter_states_df$ui_active("fsdf") - )), - column(4, div( - h4("Manual filter control"), - filter_states_df$ui_add("add_filters"), br(), - h4("Condition (i.e. call)"), # display the subset expression generated by this FilterStates - textOutput("call_df"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_df"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_df", "set NUM1 < 30", width = "100\%"), br(), - actionButton("button2_df", "set NUM2 \%in\% c(20, 21)", width = "100\%"), br(), - actionButton("button3_df", "set CHAR1 \%in\% c(\"B\", \"C\", \"D\")", width = "100\%"), br(), - actionButton("button4_df", "set CHAR2 == \"F\"", width = "100\%"), br(), - actionButton("button5_df", "set DATE <= 2020-02-02", width = "100\%"), br(), - actionButton("button6_df", "set DATETIME <= 2020-02-02", width = "100\%"), br(), - hr(), - actionButton("button7_df", "remove NUM1", width = "100\%"), br(), - actionButton("button8_df", "remove NUM2", width = "100\%"), br(), - actionButton("button9_df", "remove CHAR1", width = "100\%"), br(), - actionButton("button10_df", "remove CHAR2", width = "100\%"), br(), - actionButton("button11_df", "remove DATE", width = "100\%"), br(), - actionButton("button12_df", "remove DATETIME", width = "100\%"), br(), - hr(), - actionButton("button0_df", "clear all filters", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - filter_states_df$srv_add("add_filters") - filter_states_df$srv_active("fsdf") - - output$call_df <- renderPrint(filter_states_df$get_call()) - output$formatted_df <- renderText(filter_states_df$format()) - - observeEvent(input$button1_df, { - filter_state <- teal_slices(teal_slice("dataset", "NUM1", selected = c(0, 30))) - filter_states_df$set_filter_state(state = filter_state) - }) - observeEvent(input$button2_df, { - filter_state <- teal_slices(teal_slice("dataset", "NUM2", selected = c(20, 21))) - filter_states_df$set_filter_state(state = filter_state) - }) - observeEvent(input$button3_df, { - filter_state <- teal_slices(teal_slice("dataset", "CHAR1", selected = c("B", "C", "D"))) - filter_states_df$set_filter_state(state = filter_state) - }) - observeEvent(input$button4_df, { - filter_state <- teal_slices(teal_slice("dataset", "CHAR2", selected = c("F"))) - filter_states_df$set_filter_state(state = filter_state) - }) - observeEvent(input$button5_df, { - filter_state <- teal_slices( - teal_slice("dataset", "DATE", selected = c("2020-01-01", "2020-02-02")) - ) - filter_states_df$set_filter_state(state = filter_state) - }) - observeEvent(input$button6_df, { - filter_state <- teal_slices( - teal_slice("dataset", "DATETIME", selected = as.POSIXct(c("2020-01-01", "2020-02-02"))) - ) - filter_states_df$set_filter_state(state = filter_state) - }) - - observeEvent(input$button7_df, { - filter_state <- teal_slices(teal_slice("dataset", "NUM1")) - filter_states_df$remove_filter_state(filter_state) - }) - observeEvent(input$button8_df, { - filter_state <- teal_slices(teal_slice("dataset", "NUM2")) - filter_states_df$remove_filter_state(filter_state) - }) - observeEvent(input$button9_df, { - filter_state <- teal_slices(teal_slice("dataset", "CHAR1")) - filter_states_df$remove_filter_state(filter_state) - }) - observeEvent(input$button10_df, { - filter_state <- teal_slices(teal_slice("dataset", "CHAR2")) - filter_states_df$remove_filter_state(filter_state) - }) - observeEvent(input$button11_df, { - filter_state <- teal_slices( - teal_slice("dataset", "DATE") - ) - filter_states_df$remove_filter_state(filter_state) - }) - observeEvent(input$button12_df, { - filter_state <- teal_slices( - teal_slice("dataset", "DATETIME", selected = as.POSIXct(c("2020-01-01", "2020-02-02"))) - ) - filter_states_df$remove_filter_state(filter_state) - }) - - observeEvent(input$button0_df, filter_states_df$clear_filter_states()) -} - -if (interactive()) { - shinyApp(ui, server) -} -} \keyword{internal} \section{Super class}{ \code{\link[teal.slice:FilterStates]{teal.slice::FilterStates}} -> \code{DFFilterStates} diff --git a/man/DataframeFilteredDataset.Rd b/man/DataframeFilteredDataset.Rd index 8799d6685..bc3090110 100644 --- a/man/DataframeFilteredDataset.Rd +++ b/man/DataframeFilteredDataset.Rd @@ -8,32 +8,6 @@ The \code{DataframeFilteredDataset} \code{R6} class The \code{DataframeFilteredDataset} \code{R6} class -} -\examples{ -# use non-exported function from teal.slice -DataframeFilteredDataset <- getFromNamespace("DataframeFilteredDataset", "teal.slice") - -library(shiny) - -ds <- DataframeFilteredDataset$new(iris, "iris") -ds$set_filter_state( - teal_slices( - teal_slice(dataname = "iris", varname = "Species", selected = "virginica"), - teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5)) - ) -) -isolate(ds$get_filter_state()) -isolate(ds$get_call()) - -## set_filter_state -dataset <- DataframeFilteredDataset$new(iris, "iris") -fs <- teal_slices( - teal_slice(dataname = "iris", varname = "Species", selected = "virginica"), - teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5)) -) -dataset$set_filter_state(state = fs) -isolate(dataset$get_filter_state()) - } \keyword{internal} \section{Super class}{ diff --git a/man/DateFilterState.Rd b/man/DateFilterState.Rd index 3143c55ef..6ede7bb61 100644 --- a/man/DateFilterState.Rd +++ b/man/DateFilterState.Rd @@ -6,104 +6,6 @@ \title{\code{FilterState} object for \code{Date} data} \description{ Manages choosing a range of \code{Date}s. -} -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -DateFilterState <- getFromNamespace("DateFilterState", "teal.slice") - -library(shiny) - -filter_state <- DateFilterState$new( - x = c(Sys.Date() + seq(1:10), NA), - slice = teal_slice(varname = "x", dataname = "data"), - extract_type = character(0) -) -isolate(filter_state$get_call()) -filter_state$set_state( - teal_slice( - dataname = "data", - varname = "x", - selected = c(Sys.Date() + 3L, Sys.Date() + 8L), - keep_na = TRUE - ) -) -isolate(filter_state$get_call()) - -# working filter in an app -library(shinyjs) - -dates <- c(Sys.Date() - 100, Sys.Date()) -data_date <- c(seq(from = dates[1], to = dates[2], length.out = 100), NA) -fs <- DateFilterState$new( - x = data_date, - slice = teal_slice( - dataname = "data", varname = "x", selected = data_date[c(47, 98)], keep_na = TRUE - ) -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("DateFilterState"), - fs$ui("fs") - )), - column(4, div( - id = "outputs", # div id is needed for toggling the element - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_date"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_date"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_date"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_date", "set drop NA", width = "100\%"), br(), - actionButton("button2_date", "set keep NA", width = "100\%"), br(), - actionButton("button3_date", "set a range", width = "100\%"), br(), - actionButton("button4_date", "set full range", width = "100\%"), br(), - actionButton("button0_date", "set initial state", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - fs$server("fs") - output$condition_date <- renderPrint(fs$get_call()) - output$formatted_date <- renderText(fs$format()) - output$unformatted_date <- renderPrint(fs$get_state()) - # modify filter state programmatically - observeEvent( - input$button1_date, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) - ) - observeEvent( - input$button2_date, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) - ) - observeEvent( - input$button3_date, - fs$set_state(teal_slice(dataname = "data", varname = "x", selected = data_date[c(34, 56)])) - ) - observeEvent( - input$button4_date, - fs$set_state(teal_slice(dataname = "data", varname = "x", selected = dates)) - ) - observeEvent( - input$button0_date, - fs$set_state( - teal_slice("data", "variable", selected = data_date[c(47, 98)], keep_na = TRUE) - ) - ) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} \section{Super class}{ diff --git a/man/DatetimeFilterState.Rd b/man/DatetimeFilterState.Rd index 686caf6df..77da758dd 100644 --- a/man/DatetimeFilterState.Rd +++ b/man/DatetimeFilterState.Rd @@ -6,110 +6,6 @@ \title{\code{FilterState} object for date time data} \description{ Manages choosing a range of date-times. -} -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -DatetimeFilterState <- getFromNamespace("DatetimeFilterState", "teal.slice") - -library(shiny) - -filter_state <- DatetimeFilterState$new( - x = c(Sys.time() + seq(0, by = 3600, length.out = 10), NA), - slice = teal_slice(varname = "x", dataname = "data"), - extract_type = character(0) -) -isolate(filter_state$get_call()) -filter_state$set_state( - teal_slice( - dataname = "data", - varname = "x", - selected = c(Sys.time() + 3L, Sys.time() + 8L), - keep_na = TRUE - ) -) -isolate(filter_state$get_call()) - -# working filter in an app -library(shinyjs) - -datetimes <- as.POSIXct(c("2012-01-01 12:00:00", "2020-01-01 12:00:00")) -data_datetime <- c(seq(from = datetimes[1], to = datetimes[2], length.out = 100), NA) -fs <- DatetimeFilterState$new( - x = data_datetime, - slice = teal_slice( - varname = "x", dataname = "data", selected = data_datetime[c(47, 98)], keep_na = TRUE - ) -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("DatetimeFilterState"), - fs$ui("fs") - )), - column(4, div( - id = "outputs", # div id is needed for toggling the element - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_datetime"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_datetime"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_datetime"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_datetime", "set drop NA", width = "100\%"), br(), - actionButton("button2_datetime", "set keep NA", width = "100\%"), br(), - actionButton("button3_datetime", "set a range", width = "100\%"), br(), - actionButton("button4_datetime", "set full range", width = "100\%"), br(), - actionButton("button0_datetime", "set initial state", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - fs$server("fs") - output$condition_datetime <- renderPrint(fs$get_call()) - output$formatted_datetime <- renderText(fs$format()) - output$unformatted_datetime <- renderPrint(fs$get_state()) - # modify filter state programmatically - observeEvent( - input$button1_datetime, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) - ) - observeEvent( - input$button2_datetime, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) - ) - observeEvent( - input$button3_datetime, - fs$set_state( - teal_slice(dataname = "data", varname = "x", selected = data_datetime[c(34, 56)]) - ) - ) - observeEvent( - input$button4_datetime, - fs$set_state( - teal_slice(dataname = "data", varname = "x", selected = datetimes) - ) - ) - observeEvent( - input$button0_datetime, - fs$set_state( - teal_slice( - dataname = "data", varname = "x", selected = data_datetime[c(47, 98)], keep_na = TRUE - ) - ) - ) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} \section{Super class}{ diff --git a/man/DefaultFilteredDataset.Rd b/man/DefaultFilteredDataset.Rd index c529628da..c1e91cc26 100644 --- a/man/DefaultFilteredDataset.Rd +++ b/man/DefaultFilteredDataset.Rd @@ -6,17 +6,6 @@ \title{\code{DefaultFilteredDataset} \code{R6} class} \description{ Stores any object as inert entity. Filtering is not supported. -} -\examples{ -# use non-exported function from teal.slice -DefaultFilteredDataset <- getFromNamespace("DefaultFilteredDataset", "teal.slice") - -library(shiny) - -ds <- DefaultFilteredDataset$new(letters, "letters") -isolate(ds$get_filter_state()) -isolate(ds$get_call()) - } \keyword{internal} \section{Super class}{ diff --git a/man/EmptyFilterState.Rd b/man/EmptyFilterState.Rd index ce2e6f405..2c31539db 100644 --- a/man/EmptyFilterState.Rd +++ b/man/EmptyFilterState.Rd @@ -6,23 +6,6 @@ \title{\code{FilterState} object for empty variables} \description{ \code{FilterState} subclass representing an empty variable. -} -\examples{ -# use non-exported function from teal.slice -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -EmptyFilterState <- getFromNamespace("EmptyFilterState", "teal.slice") - -library(shiny) - -filter_state <- EmptyFilterState$new( - x = NA, - slice = teal_slice(varname = "x", dataname = "data"), - extract_type = character(0) -) -isolate(filter_state$get_call()) -filter_state$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) -isolate(filter_state$get_call()) - } \keyword{internal} \section{Super class}{ diff --git a/man/FilterStateExpr.Rd b/man/FilterStateExpr.Rd index 23c7a46fe..692ab8b14 100644 --- a/man/FilterStateExpr.Rd +++ b/man/FilterStateExpr.Rd @@ -11,56 +11,6 @@ Sister class to \code{FilterState} that handles arbitrary filter expressions. Creates a filter state around a predefined condition call (logical predicate). The condition call is independent of the data and the filter card allows no interaction (the filter is always fixed). -} -\examples{ -# use non-exported function from teal.slice -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -FilterStateExpr <- getFromNamespace("FilterStateExpr", "teal.slice") - -filter_state <- FilterStateExpr$new( - slice = teal_slice( - dataname = "x", - id = "FA", - title = "Adult females", - expr = "sex == 'F' & age >= 18" - ) -) -filter_state$get_call() - -# working filter in an app -library(shiny) -library(shinyjs) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("ChoicesFilterState"), - filter_state$ui("fs") - )), - column(8, div( - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_choices"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_choices"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_choices"), br() - )) -) - -server <- function(input, output, session) { - filter_state$server("fs") - output$condition_choices <- renderPrint(filter_state$get_call()) - output$formatted_choices <- renderText(filter_state$format()) - output$unformatted_choices <- renderPrint(filter_state$get_state()) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} \section{Methods}{ diff --git a/man/FilteredData.Rd b/man/FilteredData.Rd index 0bb1e4366..008aa4dfd 100644 --- a/man/FilteredData.Rd +++ b/man/FilteredData.Rd @@ -39,60 +39,6 @@ Common arguments are: \item \code{varname}: one of the columns in a dataset } } -\examples{ -# use non-exported function from teal.slice -FilteredData <- getFromNamespace("FilteredData", "teal.slice") - -library(shiny) - -datasets <- FilteredData$new(list(iris = iris, mtcars = mtcars)) - -# get datanames -datasets$datanames() - -datasets$set_filter_state( - teal_slices(teal_slice(dataname = "iris", varname = "Species", selected = "virginica")) -) -isolate(datasets$get_call("iris")) - -datasets$set_filter_state( - teal_slices(teal_slice(dataname = "mtcars", varname = "mpg", selected = c(15, 20))) -) - -isolate(datasets$get_filter_state()) -isolate(datasets$get_call("iris")) -isolate(datasets$get_call("mtcars")) - -\dontshow{if (requireNamespace("MultiAssayExperiment")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -### set_filter_state -library(shiny) - -data(miniACC, package = "MultiAssayExperiment") -datasets <- FilteredData$new(list(iris = iris, mae = miniACC)) -fs <- teal_slices( - teal_slice( - dataname = "iris", varname = "Sepal.Length", selected = c(5.1, 6.4), - keep_na = TRUE, keep_inf = FALSE - ), - teal_slice( - dataname = "iris", varname = "Species", selected = c("setosa", "versicolor"), - keep_na = FALSE - ), - teal_slice( - dataname = "mae", varname = "years_to_birth", selected = c(30, 50), - keep_na = TRUE, keep_inf = FALSE - ), - teal_slice(dataname = "mae", varname = "vital_status", selected = "1", keep_na = FALSE), - teal_slice(dataname = "mae", varname = "gender", selected = "female", keep_na = TRUE), - teal_slice( - dataname = "mae", varname = "ARRAY_TYPE", - selected = "", keep_na = TRUE, experiment = "RPPAArray", arg = "subset" - ) -) -datasets$set_filter_state(state = fs) -isolate(datasets$get_filter_state()) -\dontshow{\}) # examplesIf} -} \keyword{internal} \section{Methods}{ \subsection{Public methods}{ diff --git a/man/LogicalFilterState.Rd b/man/LogicalFilterState.Rd index 5d9f09778..925660fc1 100644 --- a/man/LogicalFilterState.Rd +++ b/man/LogicalFilterState.Rd @@ -6,90 +6,6 @@ \title{\code{FilterState} object for logical data} \description{ Manages choosing a logical state. -} -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -LogicalFilterState <- getFromNamespace("LogicalFilterState", "teal.slice") - -library(shiny) - -filter_state <- LogicalFilterState$new( - x = sample(c(TRUE, FALSE, NA), 10, replace = TRUE), - slice = teal_slice(varname = "x", dataname = "data") -) -isolate(filter_state$get_call()) -filter_state$set_state( - teal_slice(dataname = "data", varname = "x", selected = TRUE, keep_na = TRUE) -) -isolate(filter_state$get_call()) - -# working filter in an app -library(shinyjs) - -data_logical <- c(sample(c(TRUE, FALSE), 10, replace = TRUE), NA) -fs <- LogicalFilterState$new( - x = data_logical, - slice = teal_slice(dataname = "data", varname = "x", selected = FALSE, keep_na = TRUE) -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("LogicalFilterState"), - fs$ui("fs") - )), - column(4, div( - id = "outputs", # div id is needed for toggling the element - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_logical"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_logical"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_logical"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_logical", "set drop NA", width = "100\%"), br(), - actionButton("button2_logical", "set keep NA", width = "100\%"), br(), - actionButton("button3_logical", "set a selection", width = "100\%"), br(), - actionButton("button0_logical", "set initial state", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - fs$server("fs") - output$condition_logical <- renderPrint(fs$get_call()) - output$formatted_logical <- renderText(fs$format()) - output$unformatted_logical <- renderPrint(fs$get_state()) - # modify filter state programmatically - observeEvent( - input$button1_logical, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) - ) - observeEvent( - input$button2_logical, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) - ) - observeEvent( - input$button3_logical, - fs$set_state(teal_slice(dataname = "data", varname = "x", selected = TRUE)) - ) - observeEvent( - input$button0_logical, - fs$set_state( - teal_slice(dataname = "data", varname = "x", selected = FALSE, keep_na = TRUE) - ) - ) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} \section{Super class}{ diff --git a/man/MAEFilteredDataset.Rd b/man/MAEFilteredDataset.Rd index 7a81b9619..eab330af2 100644 --- a/man/MAEFilteredDataset.Rd +++ b/man/MAEFilteredDataset.Rd @@ -9,33 +9,6 @@ \code{MAEFilteredDataset} \code{R6} class } -\examples{ -\dontshow{if (requireNamespace("MultiAssayExperiment")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -# use non-exported function from teal.slice -MAEFilteredDataset <- getFromNamespace("MAEFilteredDataset", "teal.slice") - -data(miniACC, package = "MultiAssayExperiment") -dataset <- MAEFilteredDataset$new(miniACC, "MAE") -fs <- teal_slices( - teal_slice( - dataname = "MAE", varname = "years_to_birth", selected = c(30, 50), keep_na = TRUE - ), - teal_slice( - dataname = "MAE", varname = "vital_status", selected = "1", keep_na = FALSE - ), - teal_slice( - dataname = "MAE", varname = "gender", selected = "female", keep_na = TRUE - ), - teal_slice( - dataname = "MAE", varname = "ARRAY_TYPE", selected = "", keep_na = TRUE - ) -) -dataset$set_filter_state(state = fs) - -library(shiny) -isolate(dataset$get_filter_state()) -\dontshow{\}) # examplesIf} -} \keyword{internal} \section{Super class}{ \code{\link[teal.slice:FilteredDataset]{teal.slice::FilteredDataset}} -> \code{MAEFilteredDataset} diff --git a/man/RangeFilterState.Rd b/man/RangeFilterState.Rd index 1851d6890..8a6212646 100644 --- a/man/RangeFilterState.Rd +++ b/man/RangeFilterState.Rd @@ -7,118 +7,6 @@ \description{ Manages choosing a numeric range. } -\examples{ -# use non-exported function from teal.slice -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -RangeFilterState <- getFromNamespace("RangeFilterState", "teal.slice") - -library(shiny) - -filter_state <- RangeFilterState$new( - x = c(NA, Inf, seq(1:10)), - slice = teal_slice(varname = "x", dataname = "data") -) -isolate(filter_state$get_call()) -filter_state$set_state( - teal_slice( - dataname = "data", - varname = "x", - selected = c(3L, 8L), - keep_na = TRUE, - keep_inf = TRUE - ) -) -isolate(filter_state$get_call()) - -# working filter in an app -library(shinyjs) - -data_range <- c(runif(100, 0, 1), NA, Inf) -fs <- RangeFilterState$new( - x = data_range, - slice = teal_slice( - dataname = "data", - varname = "x", - selected = c(0.15, 0.93), - keep_na = TRUE, - keep_inf = TRUE - ) -) - -ui <- fluidPage( - useShinyjs(), - include_css_files(pattern = "filter-panel"), - include_js_files(pattern = "count-bar-labels"), - column(4, div( - h4("RangeFilterState"), - fs$ui("fs") - )), - column(4, div( - id = "outputs", # div id is needed for toggling the element - h4("Condition (i.e. call)"), # display the condition call generated by this FilterState - textOutput("condition_range"), br(), - h4("Unformatted state"), # display raw filter state - textOutput("unformatted_range"), br(), - h4("Formatted state"), # display human readable filter state - textOutput("formatted_range"), br() - )), - column(4, div( - h4("Programmatic filter control"), - actionButton("button1_range", "set drop NA", width = "100\%"), br(), - actionButton("button2_range", "set keep NA", width = "100\%"), br(), - actionButton("button3_range", "set drop Inf", width = "100\%"), br(), - actionButton("button4_range", "set keep Inf", width = "100\%"), br(), - actionButton("button5_range", "set a range", width = "100\%"), br(), - actionButton("button6_range", "set full range", width = "100\%"), br(), - actionButton("button0_range", "set initial state", width = "100\%"), br() - )) -) - -server <- function(input, output, session) { - fs$server("fs") - output$condition_range <- renderPrint(fs$get_call()) - output$formatted_range <- renderText(fs$format()) - output$unformatted_range <- renderPrint(fs$get_state()) - # modify filter state programmatically - observeEvent( - input$button1_range, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = FALSE)) - ) - observeEvent( - input$button2_range, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_na = TRUE)) - ) - observeEvent( - input$button3_range, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_inf = FALSE)) - ) - observeEvent( - input$button4_range, - fs$set_state(teal_slice(dataname = "data", varname = "x", keep_inf = TRUE)) - ) - observeEvent( - input$button5_range, - fs$set_state( - teal_slice(dataname = "data", varname = "x", selected = c(0.2, 0.74)) - ) - ) - observeEvent( - input$button6_range, - fs$set_state(teal_slice(dataname = "data", varname = "x", selected = c(0, 1))) - ) - observeEvent( - input$button0_range, - fs$set_state( - teal_slice("data", "variable", selected = c(0.15, 0.93), keep_na = TRUE, keep_inf = TRUE) - ) - ) -} - -if (interactive()) { - shinyApp(ui, server) -} -} \keyword{internal} \section{Super class}{ \code{\link[teal.slice:FilterState]{teal.slice::FilterState}} -> \code{RangeFilterState} diff --git a/man/calls_combine_by.Rd b/man/calls_combine_by.Rd index 173d50e94..ceefa7fbf 100644 --- a/man/calls_combine_by.Rd +++ b/man/calls_combine_by.Rd @@ -22,17 +22,5 @@ Combines calls with a logical operator. \details{ This function is used to combine logical predicates produced by \code{FilterState} objects to build a complete subset expression. -} -\examples{ -# use non-exported function from teal.slice -calls_combine_by <- getFromNamespace("calls_combine_by", "teal.slice") - -calls <- list( - quote(SEX == "F"), # subsetting on factor - quote(AGE >= 20 & AGE <= 50), # subsetting on range - quote(!SURV) # subsetting on logical -) -calls_combine_by(calls, "&") - } \keyword{internal} diff --git a/man/countBars.Rd b/man/countBars.Rd index 2b71cf87e..0cf86c36c 100644 --- a/man/countBars.Rd +++ b/man/countBars.Rd @@ -41,55 +41,5 @@ Each child element can have a unique \code{id} attribute to be used independentl } \description{ \code{shiny} element displaying a series of progress bars and observation counts. -} -\examples{ -# use non-exported function from teal.slice -include_js_files <- getFromNamespace("include_js_files", "teal.slice") -include_css_files <- getFromNamespace("include_css_files", "teal.slice") -countBars <- getFromNamespace("countBars", "teal.slice") -updateCountBars <- getFromNamespace("updateCountBars", "teal.slice") - -library(shiny) - -choices <- sample(as.factor(c("a", "b", "c")), size = 20, replace = TRUE) -counts <- table(choices) -labels <- countBars( - inputId = "counts", - choices = c("a", "b", "c"), - countsmax = counts, - countsnow = unname(counts) -) - -ui <- fluidPage( - div( - class = "choices_state", - include_js_files("count-bar-labels.js"), - include_css_files(pattern = "filter-panel"), - checkboxGroupInput( - inputId = "choices", - selected = levels(choices), - choiceNames = labels, - choiceValues = levels(choices), - label = NULL - ) - ) -) -server <- function(input, output, session) { - observeEvent(input$choices, { - new_counts <- counts - new_counts[!names(new_counts) \%in\% input$choices] <- 0 - updateCountBars( - inputId = "counts", - choices = levels(choices), - countsmax = counts, - countsnow = unname(new_counts) - ) - }) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/fetch_bs_color.Rd b/man/fetch_bs_color.Rd index 0cae3d9aa..9d4c1a724 100644 --- a/man/fetch_bs_color.Rd +++ b/man/fetch_bs_color.Rd @@ -18,12 +18,5 @@ Named \code{character(1)} containing a hexadecimal color representation. } \description{ Determines the color specification for the currently active Bootstrap color theme and returns one queried color. -} -\examples{ -fetch_bs_color <- getFromNamespace("fetch_bs_color", "teal.slice") -fetch_bs_color("primary") -fetch_bs_color("danger", 0.35) -fetch_bs_color("danger", "80") - } \keyword{internal} diff --git a/man/get_supported_filter_varnames.Rd b/man/get_supported_filter_varnames.Rd index 44c1a31a8..b2dc12cbc 100644 --- a/man/get_supported_filter_varnames.Rd +++ b/man/get_supported_filter_varnames.Rd @@ -16,17 +16,4 @@ get_supported_filter_varnames(data) Gets filterable variable names from a given object. The names match variables of classes in an vector \code{teal.slice:::.filterable_class}. } -\examples{ -# use non-exported function from teal.slice -get_supported_filter_varnames <- getFromNamespace("get_supported_filter_varnames", "teal.slice") - -df <- data.frame( - a = letters[1:3], - b = 1:3, - c = Sys.Date() + 1:3, - d = Sys.time() + 1:3, - z = complex(3) -) -get_supported_filter_varnames(df) -} \keyword{internal} diff --git a/man/init_filter_state.Rd b/man/init_filter_state.Rd index 56ed0d391..223197726 100644 --- a/man/init_filter_state.Rd +++ b/man/init_filter_state.Rd @@ -41,42 +41,5 @@ specifying whether condition calls should be prefixed by \code{dataname}. Possib } \description{ Initializes a \code{FilterState} object corresponding to the class of the filtered variable. -} -\examples{ -# use non-exported function from teal.slice -init_filter_state <- getFromNamespace("init_filter_state", "teal.slice") - -library(shiny) - -filter_state <- init_filter_state( - x = c(1:10, NA, Inf), - x_reactive = reactive(c(1:10, NA, Inf)), - slice = teal_slice( - varname = "varname", - dataname = "dataname" - ), - extract_type = "matrix" -) - -isolate(filter_state$get_call()) - -# working filter in an app - -ui <- fluidPage( - filter_state$ui(id = "app"), - verbatimTextOutput("call") -) -server <- function(input, output, session) { - filter_state$server("app") - - output$call <- renderText( - deparse1(filter_state$get_call(), collapse = "\n") - ) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/init_filter_states.Rd b/man/init_filter_states.Rd index 9cd7b4792..5f27e14da 100644 --- a/man/init_filter_states.Rd +++ b/man/init_filter_states.Rd @@ -37,42 +37,5 @@ Object of class \code{FilterStates}. } \description{ Initialize \code{FilterStates} object -} -\examples{ -# use non-exported function from teal.slice -init_filter_states <- getFromNamespace("init_filter_states", "teal.slice") - -df <- data.frame( - character = letters, - numeric = seq_along(letters), - date = seq(Sys.Date(), length.out = length(letters), by = "1 day"), - datetime = seq(Sys.time(), length.out = length(letters), by = "33.33 hours") -) -rf <- init_filter_states( - data = df, - dataname = "DF" -) - -library(shiny) -ui <- fluidPage( - actionButton("clear", span(icon("xmark"), "Remove all filters")), - rf$ui_add(id = "add"), - rf$ui_active("states"), - verbatimTextOutput("expr"), -) - -server <- function(input, output, session) { - rf$srv_add(id = "add") - rf$srv_active(id = "states") - output$expr <- renderText({ - deparse1(rf$get_call(), collapse = "\n") - }) - observeEvent(input$clear, rf$clear_filter_states()) -} - -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/make_c_call.Rd b/man/make_c_call.Rd index b37b28d4f..7e3d5042a 100644 --- a/man/make_c_call.Rd +++ b/man/make_c_call.Rd @@ -15,12 +15,5 @@ A \code{c} call. \description{ This function takes a vector of values and returns a \code{c} call. If the vector has only one element, the element is returned directly. -} -\examples{ -# use non-exported function from teal.slice -make_c_call <- getFromNamespace("make_c_call", "teal.slice") -make_c_call(1:3) -make_c_call(1) - } \keyword{internal} diff --git a/man/toggle_button.Rd b/man/toggle_button.Rd index dcd44c5c3..77c7d2405 100644 --- a/man/toggle_button.Rd +++ b/man/toggle_button.Rd @@ -33,58 +33,5 @@ which may contain a child \verb{} tag that specifies an icon to be displayed. \code{toggle_icon} calls the \code{toggleClass} (when \code{one_way = FALSE}) or \code{removeClass} and \code{addClass} methods (when \code{one_way = TRUE}) to change icons. \code{toggle_title} calls the \code{attr} method to modify the \code{Title} attribute of the button. -} -\examples{ -# use non-exported function from teal.slice -toggle_icon <- getFromNamespace("toggle_icon", "teal.slice") - -library(shiny) -library(shinyjs) - -ui <- fluidPage( - useShinyjs(), - actionButton("hide_content", label = "hide", icon = icon("xmark")), - actionButton("show_content", label = "show", icon = icon("check")), - actionButton("toggle_content", label = "toggle", icon = icon("angle-down")), - br(), - div( - id = "content", - verbatimTextOutput("printout") - ) -) - -server <- function(input, output, session) { - observeEvent(input$hide_content, - { - hide("content") - toggle_icon("toggle_content", c("fa-angle-down", "fa-angle-right"), one_way = TRUE) - }, - ignoreInit = TRUE - ) - - observeEvent(input$show_content, - { - show("content") - toggle_icon("toggle_content", c("fa-angle-right", "fa-angle-down"), one_way = TRUE) - }, - ignoreInit = TRUE - ) - - observeEvent(input$toggle_content, - { - toggle("content") - toggle_icon("toggle_content", c("fa-angle-right", "fa-angle-down")) - }, - ignoreInit = TRUE - ) - - output$printout <- renderPrint({ - head(faithful, 10) - }) -} -if (interactive()) { - shinyApp(ui, server) -} - } \keyword{internal} diff --git a/man/topological_sort.Rd b/man/topological_sort.Rd index 899a768bc..b3d84837f 100644 --- a/man/topological_sort.Rd +++ b/man/topological_sort.Rd @@ -16,12 +16,4 @@ in the returned list, parents appear before their children. \details{ Implementation of \code{Kahn} algorithm with a modification to maintain the order of input elements. } -\examples{ -# use non-exported function from teal.slice -topological_sort <- getFromNamespace("topological_sort", "teal.slice") - -topological_sort(list(A = c(), B = c("A"), C = c("B"), D = c("A"))) -topological_sort(list(D = c("A"), A = c(), B = c("A"), C = c("B"))) -topological_sort(list(D = c("A"), B = c("A"), C = c("B"), A = c())) -} \keyword{internal} diff --git a/man/variable_types.Rd b/man/variable_types.Rd index b5f2fff78..e50892175 100644 --- a/man/variable_types.Rd +++ b/man/variable_types.Rd @@ -17,33 +17,5 @@ Character vector of classes of \code{columns} from provided \code{data}. } \description{ Get classes of selected columns from dataset -} -\examples{ -# use non-exported function from teal.slice -variable_types <- getFromNamespace("variable_types", "teal.slice") - -variable_types( - data.frame( - x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), - stringsAsFactors = FALSE - ), - "x" -) - -variable_types( - data.frame( - x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), - stringsAsFactors = FALSE - ), - c("x", "z") -) - -variable_types( - data.frame( - x = 1:3, y = factor(c("a", "b", "a")), z = c("h1", "h2", "h3"), - stringsAsFactors = FALSE - ) -) - } \keyword{internal}