input_select: Create interactive control to select one (or more options)...

Description Usage Arguments See Also Examples

View source: R/inputs.R

Description

Usage

1
2
3
4
5
6
7
8
input_select(choices, selected = NULL, multiple = FALSE, label = "",
  id = rand_id("select_"), map = identity, selectize = FALSE)

input_radiobuttons(choices, selected = NULL, label = "",
  id = rand_id("radio_"), map = identity)

input_checkboxgroup(choices, selected = NULL, label = "",
  id = rand_id("radio_"), map = identity)

Arguments

choices

List of values to select from. If elements of the list are named then that name rather than the value is displayed to the user.

selected

The initially selected value (or multiple values if multiple = TRUE). If not specified then defaults to the first value for single-select lists and no values for multiple select lists.

multiple

Is selection of multiple items allowed?

label

Display label for the control, or NULL

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.

selectize

Whether to use selectize.js or not.

See Also

Other interactive input: input_checkbox; input_numeric, input_text; input_slider

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Dropdown
input_select(c("a", "b", "c"))
input_select(c("a", "b", "c"), multiple = TRUE)
input_select(c("a", "b", "c"), selected = "c")

# If you want to select variable names, you need to convert
# the output of the input to a name with map so that they get
# computed correctly
input_select(names(mtcars), map = as.name)

# Radio buttons
input_radiobuttons(choices = c("Linear" = "lm", "LOESS" = "loess"),
                   label = "Model type")
input_radiobuttons(choices = c("Linear" = "lm", "LOESS" = "loess"),
                   selected = "loess",
                   label = "Model type")

# Used in layer_model_predictions
mtcars %>% ggvis(~wt, ~mpg) %>%
  layer_model_predictions(model = input_radiobuttons(
    choices = c("Linear" = "lm", "LOESS" = "loess"),
    selected = "loess",
    label = "Model type"))

# Checkbox group
mtcars %>% ggvis(x = ~wt, y = ~mpg) %>%
  layer_points(
    fill := input_checkboxgroup(
      choices = c("Red" = "r", "Green" = "g", "Blue" = "b"),
      label = "Point color components",
      map = function(val) {
        rgb(0.8 * "r" %in% val, 0.8 * "g" %in% val, 0.8 * "b" %in% val)
      }
    )
  )

rpruim/ggvis2 documentation built on May 28, 2019, 2:34 a.m.