virgo basics

To create a virgo graphic pass your data into vega(), and supply some visual encodings enc(). You can then add layers with the %>%, and write the results to a file.

vega()

Create a new vega visualisation

enc()

Map data variables to visual encodings

Layers

To add visual layers to a graphic, you need to specify a mark which depends on your data and visual encoding.

mark_arc() mark_ribbon() mark_boxplot() mark_circle() mark_errorband() mark_image() mark_line() mark_point() mark_rect() mark_rule() mark_square() mark_text() mark_tick() mark_trail() mark_area() mark_bar() mark_errorbar() mark_histogram() mark_step() mark_density() mark_bin2d() mark_streamgraph() mark_smooth() mark_mosaic() mark_blank()

Add new marks to vega() visualisation

Scales

To modify how encodings are translated from the data to the visual appearance of a graphic you need to specify a scale.

scale_x() scale_y() scale_color() scale_colour() scale_size() scale_shape()

Vega scales

Facets and Concatenation

To generate small multiples and display different subsets of the data, you need to facet. To layout graphics along side one another you need to concatenate

facet_views()

Facet data views by rows and columns

hconcat() vconcat()

Concatenate views

resolve_views()

Resolve scale and guide for layered and multi-view displays

Interactivity

Interactivity allows you to manipulate a virgo graphic, either through direct selection using the select_ functions or by binding data to an interface like a button or slider with the input_ functions. These selections can drive aesthetic transformations of a graphic or the data. See vignette("selections.Rmd") for details

encode_if()

Conditional encoding selection

select_single() select_multi() select_interval() select_legend() select_domain() select_bind()

Initiate a selection

input_slider() input_radio() input_select() input_textbox() input_checkbox() input_color() input_colour() input_date() input_datetime() input_month() input_week()

HTML elements that bind to selections

Data transformations

Data transformations can performed directly on the client with the vg_ family of functions.

vg_sum() vg_min() vg_max() vg_mean() vg_median() vg_count() vg_distinct() vg_argmin() vg_argmax()

Interactive aggregation operations

vg_year() vg_quarter() vg_month() vg_yearmonth() vg_date() vg_week() vg_day() vg_dayofyear() vg_hours() vg_minutes() vg_seconds() vg_milliseconds()

Interactive time unit operations

vg_window_sum() vg_window_mean() vg_window_rank() vg_window_count() vg_cumsum() vg_cummean() vg_row_number() vg_rank() vg_dense_rank() vg_percent_rank() vg_cume_dist() vg_ntile() vg_lead() vg_lag()

Interactive window operations

Customisation

The appearance of a virgo graphic can be configured to modify all the non-data elements of a chart.

config() config_ggplot()

Vega theme configurations

Data

virgo comes built in with the following data sets

melbweather

Melbourne microclimate measurements

Utilities

To assist with using virgo in R Markdown or packages.

vega_serialise_data() vega_serialize_data()

Serialise data

image

Create or write image

vw_set_base_url

Set base URL