encode_detail {vegalite}R Documentation

Encode detail "channel"

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.

detail channel allows providing an additional grouping field (level) for grouping data in aggregation without mapping data to a specific visual channel.

Usage

encode_detail(vl, field = NULL, type, aggregate = NULL, sort = NULL)

Arguments

vl

Vega-Lite object created by vegalite

field

single element character vector naming the column

type

the encoded field’s type of measurement. This can be either a full type name (quantitative, temporal, ordinal, and nominal) or an initial character of the type name (Q, T, O, N). This property is case insensitive. If auto is used, the type will be guessed (so you may want to actually specify it if you want consistency).

aggregate

perform aggregaton on field. See Supported Aggregation Options for more info on valid operations. Leave NULL for no aggregation.

sort

either one of ascending, descending or (for ordinal scales) the result of a call to sort_def

Note

right now, type == "auto" just assume "quantitative". It will eventually get smarter, but you are better off specifying it.

References

Vega-Lite Encoding spec

Examples

vegalite() %>%
  cell_size(200, 200) %>%
  add_data("https://vega.github.io/vega-editor/app/data/stocks.csv") %>%
  encode_x("date", "temporal") %>%
  encode_y("price", "quantitative") %>%
  encode_detail("symbol", "nominal") %>%
  mark_line()

[Package vegalite version 0.6.1 Index]