Skip to content

Commit

Permalink
548 remove private/internal examples (#550)
Browse files Browse the repository at this point in the history
Closes #548
  • Loading branch information
m7pr authored and cicdguy committed Feb 6, 2024
1 parent 0e5f574 commit 7af6b37
Show file tree
Hide file tree
Showing 41 changed files with 0 additions and 2,139 deletions.
42 changes: 0 additions & 42 deletions R/FilterState-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,6 @@
#' - `"list"` `varname` in the condition call will be returned as `<dataname>$<varname>`
#' - `"matrix"` `varname` in the condition call will be returned as `<dataname>[, <varname>]`
#'
#' @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,
Expand Down Expand Up @@ -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) {
Expand Down
103 changes: 0 additions & 103 deletions R/FilterStateChoices.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
97 changes: 0 additions & 97 deletions R/FilterStateDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
103 changes: 0 additions & 103 deletions R/FilterStateDatettime.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 7af6b37

Please sign in to comment.