mwSelect: Add a Select list input to a manipulateWidget gadget

Description Usage Arguments Value See Also Examples

View source: R/inputs.R

Description

Add a Select list input to a manipulateWidget gadget

Usage

1
2
3
4
5
6
7
8
mwSelect(
  choices = value,
  value = NULL,
  label = NULL,
  ...,
  multiple = FALSE,
  .display = TRUE
)

Arguments

choices

Vector or list of choices. If it is named, then the names rather than the values are displayed to the user.

value

Initial value of the input. If not specified, the first choice is used.

label

Display label for the control. If NULL, the name of the corresponding variable is used.

...

Other arguments passed to functionselectInput.

multiple

Is selection of multiple items allowed?

.display

expression that evaluates to TRUE or FALSE, indicating when the input control should be shown/hidden.

Value

A function that will generate the input control.

See Also

Other controls: mwCheckboxGroup(), mwCheckbox(), mwDateRange(), mwDate(), mwGroup(), mwNumeric(), mwPassword(), mwRadio(), mwSelectize(), mwSharedValue(), mwSlider(), mwText()

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
if (require(plotly)) {
  mydata <- data.frame(x = 1:100, y = rnorm(100))

  manipulateWidget(
    {
      mode <- switch(type, points = "markers", lines = "lines", both = "markers+lines")
      plot_ly(mydata, x=~x, y=~y, type = "scatter", mode = mode)
    },
    type = mwSelect(c("points", "lines", "both"))
  )

  Sys.sleep(0.5)

  # Select multiple values
  manipulateWidget(
    {
      if (length(species) == 0) mydata <- iris
      else mydata <- iris[iris$Species %in% species,]

      plot_ly(mydata, x = ~Sepal.Length, y = ~Sepal.Width,
              color = ~droplevels(Species), type = "scatter", mode = "markers")
    },
    species = mwSelect(levels(iris$Species), multiple = TRUE)
  )
}

manipulateWidget documentation built on May 31, 2021, 9:10 a.m.