Learn R Programming

vegalite (version 0.6.1)

bin_x: Group continuous data values (x-axis)

Description

The "bin" property is for grouping quantitative, continuous data values of a particular field into smaller number of “bins” (e.g., for a histogram).

Usage

bin_x(vl, min = NULL, max = NULL, base = NULL, step = NULL, steps = NULL, minstep = NULL, div = NULL, maxbins = NULL)

Arguments

vl
Vega-Lite object
min
the minimum bin value to consider.
max
the maximum bin value to consider.
base
the number base to use for automatic bin determination.
step
an exact step size to use between bins.
steps
an array of allowable step sizes to choose from.
minstep
minimum allowable step size (particularly useful for integer values).
div
Scale factors indicating allowable subdivisions. The default value is [5, 2], which indicates that for base 10 numbers (the default base), the method may consider dividing bin sizes by 5 and/or 2. For example, for an initial step size of 10, the method can check if bin sizes of 2 (= 10/5), 5 (= 10/2), or 1 (= 10/(5*2)) might also satisfy the given constraints.
maxbins
the maximum number of allowable bins.

References

Vega-Lite Binning

Examples

Run this code
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/movies.json") %>%
  encode_x("IMDB_Rating", "quantitative") %>%
  encode_y("Rotten_Tomatoes_Rating", "quantitative") %>%
  encode_size("*", "quantitative", aggregate="count") %>%
  bin_x(maxbins=10) %>%
  bin_y(maxbins=10) %>%
  mark_point()

Run the code above in your browser using DataLab