sort_def {vegalite}R Documentation

Create a sort definition object

Description

You can sort by aggregated value of another “sort” field by creating a sort field definition object. All three properties must be non-NULL.

Usage

sort_def(field, op = NULL, order = c("ascending", "descending"))

Arguments

field

the field name to aggregate over.

op

a valid aggregation operator.

order

either ascending or descending

Examples

vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", type="quantitative", aggregate="mean") %>%
  encode_y("Origin", "ordinal", sort=sort_def("Horsepower", "mean")) %>%
  mark_bar()

[Package vegalite version 0.6.1 Index]