add_data {vegalite} | R Documentation |
Add data to a Vega-Lite spec
Description
Vega-Lite is more lightweight than full Vega. However, the spec is flexible enough to support embedded data or using external sources that are in JSON, CSV or TSV format.
Usage
add_data(vl, source, format_type = NULL)
Arguments
vl |
a Vega-Lite object |
source |
you can specify a (fully qualified) URL or an existing
|
format_type |
if |
References
Examples
dat <- jsonlite::fromJSON('[
{"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
{"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
{"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
]')
vegalite() %>%
add_data(dat) %>%
encode_x("a", "ordinal") %>%
encode_y("b", "quantitative") %>%
mark_bar()