Skip to contents

When used within filter's GUI input method, the component is responsible for updating `keep_na` filter parameter.

Use `.update_keep_na_input` inside filter's GUI update method to update the output based on the filter state.

Usage

.keep_na_input(
  input_id,
  filter,
  cohort,
  msg_fun = function(x) glue::glue("Keep missing values ({x})")
)

.update_keep_na_input(
  session,
  input_id,
  filter,
  cohort,
  msg_fun = function(x) glue::glue("Keep missing values ({x})")
)

Arguments

input_id

Id of the keep na input.

filter

Filter object.

cohort

Cohort object.

msg_fun

Function taking number of missing values as an argument and returning missing values label.

session

Shiny session object.

Value

Nested list of `shiny.tag` objects storing html structure of the input, or no value in case of usage 'update' method.

Examples

library(magrittr)
library(cohortBuilder)

librarian_source <- set_source(as.tblist(librarian))
coh <- cohort(
  librarian_source,
  filter(
    "range", id = "copies", name = "Copies", dataset = "books",
    variable = "copies", range = c(5, 12)
  )
) %>% run()
.keep_na_input("keep_na", coh$get_filter("1", "copies"), coh)
#> <div class="form-group shiny-input-container cb_na_input">
#>   <div class="checkbox">
#>     <label>
#>       <input id="keep_na-keep_na" type="checkbox" class="shiny-input-checkbox" checked="checked"/>
#>       <span>Keep missing values (0)</span>
#>     </label>
#>   </div>
#> </div>