Learn R Programming

yonder (version 0.1.0)

rangeInput: Inputs for numeric ranges

Description

Use rangeInput() and intervalInput() to allow users to select from a range of numeric values. For a slider input with non-numeric values refer to sliderInput().

Usage

rangeInput(id, min = 0, max = 100, default = min, step = 1, ...,
  ticks = TRUE, labels = 4, prefix = NULL, suffix = NULL,
  fill = TRUE)

intervalInput(id, min = 0, max = 100, default = c(min, max), step = 1, ..., ticks = TRUE, labels = 4, prefix = NULL, suffix = NULL, draggable = FALSE)

Arguments

id

A character string specifying the id of the reactive input.

min

A number specifying the minimum value of the input, defaults to 0.

max

A number specifying the maximum value of the input, defaults to 100.

default

A numeric vector between min and max specifying the default value of the input.

For rangeInput(), a single number, defaults to min.

For intervalInput(), a vector of two numbers, defaults to c(min, max).

step

A number specifying the interval step of the input, defaults to 1.

...

Additional named arguments passed as HTML attributes to the parent element.

ticks

One of TRUE or FALSE specifying if tick marks are added to the input, defaults to TRUE.

labels

One of TRUE, FALSE, or a number specifying how labels are applied to tick marks.

If numeric, labels specifies the exact number of tick mark labels added to the input.

If TRUE, labels are added to the tick marks and the number of labels is determined by step.

If FALSE, labels are not added to the tick marks.

prefix

A character string specifying a prefix for the input value, defaults to NULL, in which case a prefix is not prepended.

suffix

A character string specifying a suffix for the input value, defaults to NULL, in which case a prefix is not appended.

fill

One of TRUE or FALSE specifying whether the filled portion of a range or slider input is shown, defaults to TRUE.

draggable

One of TRUE or FALSE specifying if the user can drag the interval between an interval input's two sliders, defaults to FALSE. If TRUE, the slider interval may be dragged with the cursor.

See Also

Other inputs: buttonGroupInput, buttonInput, checkboxInput, chipInput, fileInput, formInput, groupInput, listGroupInput, menuInput, navInput, radioInput, selectInput, sliderInput, textInput

Examples

Run this code
# NOT RUN {
### Range inputs

# }
# NOT RUN {
<!-- % <script> -->
# }
# NOT RUN {
<!-- % $(function() { -->
# }
# NOT RUN {
<!-- %   $(".yonder-range").each(function() { -->
# }
# NOT RUN {
<!-- %     $(this.querySelector("input")).ionRangeSlider(); -->
# }
# NOT RUN {
<!-- %   }); -->
# }
# NOT RUN {
<!-- % }); -->
# }
# NOT RUN {
<!-- % </script> -->
# }
# NOT RUN {
# Select from a range of numeric values.

rangeInput(id = "range1") %>%
  background("yellow")

### Increase the number of labels

rangeInput(
  id = "range2",
  default = 30,
  labels = 8
) %>%
  background("purple")

### Increase thumb step

# We'll hide the filled portion of the input with `fill` and change how
# tick marks are placed with `snap`.

rangeInput(
  id = "range3",
  step = 10,  # <-
  snap = TRUE,
  fill = FALSE
) %>%
  background("red")

### Interval inputs

# Select an interval from a range of numeric values. Intervals are draggable
# by default, this can be toggled off with `draggable = FALSE`.

intervalInput(
  id = "interval1",
  default = c(45, 65)
) %>%
  background("blue")

# }

Run the code above in your browser using DataLab