updating-data-statistics | R Documentation |
The function should assign rendering that displays data source statistics to the valid output. By default, the output is placed within .render_filters method.
.update_data_stats(source, ...)
## Default S3 method:
.update_data_stats(source, step_id, cohort, session, ...)
## S3 method for class 'tblist'
.update_data_stats(source, step_id, cohort, session, ...)
source |
Source object. |
... |
Extra arguments passed to a specific method. |
step_id |
Id if filtering step. |
cohort |
Cohort object. |
session |
Shiny session object. |
When rendering the output, a good practice is to use cached data statistics available with 'cohort$get_cache(step_id)'. This way, you omit running additional computations which results with performance improvement.
No return value, used for side effect which assigning Cohort data statistics to the 'output' object.
source-gui-layer
if (interactive()) {
library(magrittr)
library(shiny)
library(cohortBuilder)
library(shinyCohortBuilder)
ui <- fluidPage(
sliderInput("step_two_max", "Max step two copies", min = 6, max = 12, value = 8),
uiOutput("2-stats_books")
)
server <- function(input, output, session) {
coh <- cohort(
set_source(as.tblist(librarian)),
step(
filter(
"range", id = "copies", dataset = "books",
variable = "copies", range = c(5, 12)
)
),
step(
filter(
"range", id = "copies", dataset = "books",
variable = "copies", range = c(6, 8)
)
)
) %>% run()
coh$attributes$stats <- c("pre", "post")
observeEvent(input$step_two_max, {
coh$update_filter("copies", step_id = 2, range = c(6, input$step_two_max))
run(coh, min_step_id = "2")
.update_data_stats(coh$get_source(), step_id = "2", cohort = coh, session = session)
})
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.