Description Usage Arguments Note References Examples
Grouping data is another important operation in visualizing data. For
aggregated plots, all encoded fields without aggregate functions are used as
grouping fields in the aggregation (similar to fields in GROUP BY in SQL).
For line and area marks, mapping a data field to color or shape channel will
group the lines and stacked areas by the field.
order channel sorts the layer order or stacking order (for stacked charts) of
the marks while path channel sorts the order of data points in line marks.
1 |
vl |
Vega-Lite object created by |
field |
single element character vector naming the column |
type |
the encoded field’s type of measurement. This can be either a full type
name ( |
aggregate |
perform aggregaton on |
sort |
either one of |
right now, type
== "auto
" just assume "quantitative
". It
will eventually get smarter, but you are better off specifying it.
1 2 3 4 5 6 7 8 | vegalite() %>%
cell_size(200, 200) %>%
add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
encode_x("Horsepower", "quantitative") %>%
encode_y("Miles_per_Gallon", "quantitative") %>%
encode_color("Origin", "nominal") %>%
encode_order("Origin", "ordinal", sort="descending") %>%
mark_point()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.