rendering-filters {shinyCohortBuilder} | R Documentation |
Render filtering panels for all the filters included in Cohort
Description
The method exported only for custom extensions use.
Usage
.render_filters(source, ...)
## Default S3 method:
.render_filters(source, cohort, step_id, ns, ...)
## S3 method for class 'tblist'
.render_filters(source, cohort, step_id, ns, ...)
Arguments
source |
Source object. |
... |
Extra arguments passed to a specific method. |
cohort |
Cohort object. |
step_id |
Id of the step. |
ns |
Namespace function. |
Details
Within the method you should define source data stats output (see .update_data_stats), and define a loop that renders filtering panel for each filter (using .render_filter).
Value
Nested list of 'shiny.tag' objects storing html structure of filter input panels.
See Also
Examples
if (interactive()) {
library(magrittr)
library(shiny)
library(cohortBuilder)
library(shinyCohortBuilder)
ui <- fluidPage(
actionButton("add_filter", "Add Filter"),
div(id = "filter_container")
)
server <- function(input, output, session) {
add_gui_filter_layer <- function(public, private, ...) {
private$steps[["1"]]$filters$copies$gui <- .gui_filter(
private$steps[["1"]]$filters$copies
)
private$steps[["1"]]$filters$registered$gui <- .gui_filter(
private$steps[["1"]]$filters$registered
)
}
add_hook("post_cohort_hook", add_gui_filter_layer)
coh <- cohort(
set_source(as.tblist(librarian)),
filter(
"range", id = "copies", name = "Copies", dataset = "books",
variable = "copies", range = c(5, 12)
),
filter(
"date_range", id = "registered", name = "Registered", dataset = "borrowers",
variable = "registered", range = c(as.Date("2010-01-01"), Inf)
)
) %>% run()
coh$attributes$session <- session
coh$attributes$feedback <- TRUE
observeEvent(input$add_filter, {
insertUI(
"#filter_container",
ui = .render_filters(
coh$get_source(),
cohort = coh,
step_id = "1",
ns = function(x) x
))
}, ignoreInit = TRUE, once = TRUE)
}
shinyApp(ui, server)
}
[Package shinyCohortBuilder version 0.2.1 Index]