input_checkbox: Create an interactive checkbox.

View source: R/inputs.R

input_checkboxR Documentation

Create an interactive checkbox.

Description

Create an interactive checkbox.

Usage

input_checkbox(
  value = FALSE,
  label = "",
  id = rand_id("checkbox_"),
  map = identity
)

Arguments

value

Initial value (TRUE or FALSE).

label

Display label for the control, or NULL for no label.

id

A unique identifier for this input. Usually generated automatically.

map

A function with single argument x, the value of the control on the client. Returns a modified value.

See Also

Other interactive input: input_select(), input_slider(), input_text()

Examples


input_checkbox(label = "Confidence interval")
input_checkbox(label = "Confidence interval", value = TRUE)

# Used in layer_smooths
mtcars %>% ggvis(~wt, ~mpg) %>%
  layer_smooths(se = input_checkbox(label = "Confidence interval"))

# Used with a map function, to convert the boolean to another type of value
model_type <- input_checkbox(label = "Use flexible curve",
  map = function(val) if(val) "loess" else "lm")
mtcars %>% ggvis(~wt, ~mpg) %>%
  layer_model_predictions(model = model_type)

ggvis documentation built on May 29, 2024, 1:12 a.m.