https://github.com/r-world-devs/shinyCohortBuilder
https://github.com/r-world-devs/shinyCohortBuilder
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/r-world-devs/shinyCohortBuilder
- Owner: r-world-devs
- License: other
- Created: 2022-05-22T19:04:12.000Z (almost 3 years ago)
- Default Branch: dev
- Last Pushed: 2024-10-24T08:57:29.000Z (6 months ago)
- Last Synced: 2024-10-25T06:46:06.975Z (6 months ago)
- Language: R
- Homepage: https://r-world-devs.github.io/shinyCohortBuilder/
- Size: 4.9 MB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 31
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - r-world-devs/shinyCohortBuilder - (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = TRUE,
echo = TRUE,
message = TRUE,
warning = TRUE,
fig.width = 8,
fig.height = 6,
dpi = 200,
fig.align = "center",
fig.path = "man/figures/README-"
)
library(magrittr)
library(cohortBuilder)
library(shinyCohortBuilder)
set.seed(123)
old_opts <- options()
options(tibble.width = Inf)
iris <- tibble::as.tibble(iris)
options("tibble.print_max" = 5)
options("tibble.print_min" = 5)
pkg_version <- read.dcf("DESCRIPTION", fields = "Version")[1, 1]
```# shinyCohortBuilder
Move your [cohortBuilder](https://r-world-devs.github.io/cohortBuilder/) workflow to Shiny.

[`&color=ff69b4)](https://r-world-devs.github.io/shinyCohortBuilder/)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)## Installation
```{r, eval = FALSE}
# CRAN version
install.packages("shinyCohortBuilder")# Latest development version
remotes::install_github("https://github.com/r-world-devs/shinyCohortBuilder")
```## Overview
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):```{r}
librarian_source <- set_source(as.tblist(librarian))
librarian_cohort <- 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`:
```{r, eval = FALSE}
library(shiny)ui <- fluidPage(
sidebarLayout(
sidebarPanel(
cb_ui("librarian")
),
mainPanel()
)
)server <- function(input, output, session) {
cb_server("librarian", librarian_cohort)
}shinyApp(ui, server)
```You may listen to cohort data changes with `input[[-data-updated]]`:
```{r, eval = FALSE}
library(shiny)ui <- fluidPage(
sidebarLayout(
sidebarPanel(
cb_ui("librarian")
),
mainPanel(
verbatimTextOutput("cohort_data")
)
)
)server <- function(input, output, session) {
cb_server("librarian", librarian_cohort)
output$cohort_data <- renderPrint({
input[["librarian-data-updated"]]
get_data(librarian_cohort)
})
}shinyApp(ui, server)
```Or run filtering panel locally what just makes your work with `cohortBuilder` easier:
```{r, eval = FALSE}
gui(librarian_cohort)
```
If you're interested in more features of `shinyCohortBuilder` please visit the package [website](https://r-world-devs.github.io/shinyCohortBuilder/).
## Acknowledgement
Special thanks to:
- [Kamil Wais](mailto:[email protected]) for highlighting the need for the package and its relevance to real-world applications.
- [Adam Foryś](mailto:[email protected]) for technical support, numerous suggestions for the current and future implementation of the package.
- [Paweł Kawski](mailto:[email protected]) for indication of initial assumptions about the package based on real-world medical data.## Getting help
In a case you found any bugs, have feature request or general question please file an issue at the package [Github](https://github.com/r-world-devs/shinyCohortBuilder/issues).
You may also contact the package author directly via email at [[email protected]](mailto:[email protected]).```{r, include = FALSE}
options(old_opts)
```