validate_plot_args: Validate plot arguments

Description Usage Arguments Value

View source: R/validations.R

Description

Helper function for common validations to demViz plotting functions. Also includes prep of aesthetics input.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
validate_plot_args(
  dt,
  plot_title,
  x_col,
  x_axis_title,
  y_col,
  y_axis_title,
  y_axis_commas = NULL,
  y_lb = NULL,
  y_ub = NULL,
  ribbon_alpha = NULL,
  point_col = NULL,
  equivalence_line = NULL,
  facet_type = NULL,
  facet_form = NULL,
  facet_scales = NULL,
  scale_manual = NULL
)

Arguments

dt

[data.table()]
The data.table with the values to be plotted.

plot_title

[character(1)]
Overall title of the plot.

x_col

[character(1)]
Name of the column in dt that corresponds to x-value of each line.

x_axis_title

[character(1)]
X-axis title.

y_col

[character(1)]
Name of the column in dt that corresponds to y-value of each line.

y_axis_title

[character(1)]
X-axis title.

y_axis_commas

[logical(1)]
Whether the y-axis scale labels should use comma formatting (scales::comma). Default is FALSE.

y_lb

[character(1)]
Name of the column in dt that corresponds to the lower bound of the y_col variable. Default is NULL and is not plotted.

y_ub

[character(1)]
Name of the column in dt that corresponds to the upper bound of the y_col variable. Default is NULL and is not plotted.

ribbon_alpha

[numeric(1)]
The alpha value for the ggplot2::geom_ribbon call. Default is '0.2'.

point_col

[character(1)]
Name of the column in dt that differentiates between values that should be plotted as a line versus a point. This column should be made up of logical values, with 'TRUE' indicating a point.

equivalence_line

[logical(1)]
Whether to add a line with slope 1 and intercept 0 to show where x = y. Default FALSE.

facet_type

[character(1)]
Whether to use gplot2::facet_wrap ('wrap') or gplot2::facet_grid ('grid'). Default is 'grid'. Can be NULL if no faceting is required.

facet_form

[character(1)]
String representing the formula that defines the rows and/or columns in the facet call.

facet_scales

[character(1)]
scales argument to gplot2::facet_wrap or gplot2::facet_grid. Should scales be 'fixed, 'free', or free in one dimension ('free_x', 'free_y')? Default is 'free_y'.

scale_manual

[list(1)]
Defines the manual accessory aesthetics to be used when plotting the lines (and points). See Details.

Value

[list()]
aesthetics prepped


ihmeuw-demographics/demViz documentation built on Feb. 6, 2021, 11:10 p.m.