Skip to contents

`mod_inp_n_choices_server()` Server logic

`mod_inp_n_choices_ui()` UI of the module

`get_n_policy_types()` returns valid types of the n-policy input

`make_n_choice_ui()` internal function that creates UI for the n-policy input#'

`update_n_choice_ui()` internal function used to update the n-policy input.

`test_mod_inp_n_choices_all_ui()` and `test_mod_inp_n_choices()` miscellaneous testing functions that rerun shiny apps.

A shiny Module.

Usage

mod_inp_n_choices_server(
  id,
  min = reactive(1),
  max = reactive(4),
  value = reactive(2),
  n_policy_type = reactive(get_n_policy_types()[[1]]),
  n_policy_update = reactive(NULL),
  ...
)

mod_inp_n_choices_ui(id)

make_n_choice_ui(
  ns = NS(NULL),
  value = 1,
  min = 1,
  max = 2,
  n_policy_type = "slider",
  ...
)

get_n_policy_types()

update_n_choice_ui(
  input,
  output,
  session,
  new_n_choices = NULL,
  n_policy_type = get_n_policy_types()[[1]],
  ...
)

test_mod_inp_n_choices(id = NULL)

test_mod_inp_n_choices_all_ui(id = NULL)

Arguments

id, input, output, session

Internal parameters for shiny.

min, max, value, n_policy_type, n_policy_update

reactive numeric and strings similar to params in `make_n_choice_ui()`

value, min, max

numeric with number of choices selected, minimum and maximum

n_policy_type

reactive string with the type of the n-policy input, one of "numericInline", "numeric", "slider", "dropdown", and "none". Use `get_n_policy_types()` to check valid types.

...

not used

ns

namespace function to wrap into IDs around `NS(...)`.

new_n_choices

new value of policy choices to update to.

Examples

if (FALSE) { # interactive()

test_mod_inp_n_choices()
test_mod_inp_n_choices_all_ui()
}