This function allows the user to choose from a menu of prepackaged plotting styles (or to pass your own) that are designed to facilitate data comparison between groups. Plot functions are specific to one type of data (numeric or categorical) and will only use those columns when building plots. For example, histograms are only useful for numeric data, so categorical type data is ignored.

build_plots(
  stack,
  plot_fun,
  ...,
  group_var = "flyover_id_",
  keep_type = NULL,
  ncores = 1,
  plot_mods = NULL
)

Arguments

stack

Tabular data that inherits from data.frame. This is recommended to be the output of stack_data but can be built by the user. It is coerced to a tibble.

plot_fun

The flyover plotting function to apply to the data. The user may also supply a custom function, but must be careful to match that function with the appropriate keep_type argument. Note that this function must be passed without parentheses.

...

Additional arguments to pass to the geom of the supplied flyover plot function. Use this for further modifications to the plots if needed.

group_var

Character string; the column name that represents the source of the data. It will be used as a grouping variable in the subsequent plots. The default value comes from the grouping column created by default in stack_data.

keep_type

Depending on the type of plot desired, only numeric or categorical data can be used. By default the column type is determined by the flyover plotting function passed to the plot_fun argument. If a flyover plot is passed, this argument is ignored. However, if the user specifies a custom plotting function, the keep_type argument must be set to one of "numeric", "categorical", or "both". Passing "categorical" will keep character, factor, and logical column types.

ncores

Number of cores to use for processing plots. Plot creation can be parallelized by setting ncores > 1. Note this uses the built-in parallel package which does not support Windows, so this argument is ignored for Windows systems.

plot_mods

List containing additional layers to the ggplot2 call such as theme changes, different color scales, etc. Each layer should be a separate list element. See ?ggplot2::`+.gg` for more details.

Value

A tibble containing, for each relevant variable of the input data, a row with a plot object and data frame of cognostics for the trelliscope display. The tibble can then be passed to build_display to create the trelliscope output.