encode_path {vegalite} | R Documentation |
Encode detail "path"
Description
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.
By default, line marks order their points in their paths by the field of
channel x or y. However, to show a pattern of data change over time between x & y
we use path channel to sort points in a paritcular order (e.g. by time).
Usage
encode_path(vl, field = NULL, type, aggregate = NULL, sort = NULL)
Arguments
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 |
Note
right now, type
== "auto
" just assume "quantitative
". It
will eventually get smarter, but you are better off specifying it.
References
Examples
vegalite() %>%
cell_size(300, 300) %>%
add_data("https://vega.github.io/vega-editor/app/data/driving.json") %>%
encode_x("miles", "quantitative") %>%
encode_y("gas", "quantitative") %>%
encode_path("year", "temporal") %>%
scale_x_linear(zero=FALSE) %>%
scale_y_linear(zero=FALSE) %>%
mark_line()