Move your cohortBuilder workflow to Shiny.
# CRAN version
install.packages("shinyCohortBuilder")
# Latest development version
::install_github("https://github.com/r-world-devs/shinyCohortBuilder") remotes
With shinyCohortBuilder
you can use
cohortBuilder
features within your shiny application.
Configure Source and Cohort filters with cohortBuilder
(set value/range
to NA
to select all the
options / the whole range, and active = FALSE
to collapse
filter in GUI):
<- set_source(as.tblist(librarian))
librarian_source <- cohort(
librarian_cohort
librarian_source,filter(
"discrete", id = "author", dataset = "books",
variable = "author", value = "Dan Brown",
active = FALSE
),filter(
"range", id = "copies", dataset = "books",
variable = "copies", range = c(5, 10),
active = FALSE
),filter(
"date_range", id = "registered", dataset = "borrowers",
variable = "registered", range = c(as.Date("2010-01-01"), Inf),
active = FALSE
) )
And apply in your application with cb_ui
and
cb_server
:
library(shiny)
<- fluidPage(
ui sidebarLayout(
sidebarPanel(
cb_ui("librarian")
),mainPanel()
)
)
<- function(input, output, session) {
server cb_server("librarian", librarian_cohort)
}
shinyApp(ui, server)
You may listen to cohort data changes with
input[[<cohort-id>-data-updated]]
:
library(shiny)
<- fluidPage(
ui sidebarLayout(
sidebarPanel(
cb_ui("librarian")
),mainPanel(
verbatimTextOutput("cohort_data")
)
)
)
<- function(input, output, session) {
server cb_server("librarian", librarian_cohort)
$cohort_data <- renderPrint({
output"librarian-data-updated"]]
input[[get_data(librarian_cohort)
})
}
shinyApp(ui, server)
Or run filtering panel locally what just makes your work with
cohortBuilder
easier:
gui(librarian_cohort)
If you’re interested in more features of
shinyCohortBuilder
please visit the package website.
Special thanks to:
In a case you found any bugs, have feature request or general question please file an issue at the package Github. You may also contact the package author directly via email at krystian8207@gmail.com.