R: Create a picker control

picker {manipulate} | R Documentation

## Create a picker control

### Description

Create a picker control to enable manipulation of plot variables based on a set of fixed choices.

### Usage

    picker(..., initial = NULL, label = NULL)

### Arguments

`...` | Arguments containing objects to be presented as choices for the picker (or a list containing the choices). If an element is named then the name is used to display it within the picker. If an element is not named then it is displayed within the picker using `as.character`.
`initial` | Initial value for picker. Value must be present in the list of choices specified. If not specified defaults to the first choice.
`label` | Display label for picker. Defaults to the variable name if not specified.

### Value

An object of class "manipulator.picker" which can be passed to the `manipulate` function.

### See Also

`manipulate`, `slider`, `checkbox`, `button`

### Examples

    ## Not run:

    ## Filtering data with a picker
    manipulate(
      barplot(as.matrix(longley[,factor]),
              beside = TRUE, main = factor),
      factor = picker("GNP", "Unemployed", "Employed"))

    ## Create a picker with labels
    manipulate(
      plot(pressure, type = type),
      type = picker("points" = "p", "line" = "l", "step" = "s"))

    ## Picker with groups
    manipulate(
      barplot(as.matrix(mtcars[group,"mpg"]), beside=TRUE),
      group = picker("Group 1" = 1:11,
                     "Group 2" = 12:22,
                     "Group 3" = 23:32))

    ## Histogram w/ picker to select type
    require(lattice)
    require(stats)
    manipulate(
      histogram(~ height | voice.part,
                data = singer, type = type),
      type = picker("percent", "count", "density"))

    ## End(Not run)

[Package manipulate version 1.0.1 Index]