encode_color: Encode color "channel"

Description Usage Arguments Note References Examples

View source: R/encoding.r

Description

Encode color "channel"

Usage

1
2
encode_color(vl, field = NULL, type, value = NULL, 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).

value

scale value

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

1
2
3
4
5
6
7
vegalite() %>%
  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_shape("Origin", "nominal") %>%
  mark_point()

vegalite documentation built on May 2, 2019, 10:46 a.m.