settings_units: Visualization Settings for Specified Units

Description Usage Arguments Value See Also Examples

View source: R/settings_units.R

Description

A series of arguments to detect the appropriate visualization labels and settings to apply to a dataset provided said dataset and a varaible of interest. Additionally, an optional "cap" value (and custom color) can be provided in order to distinguish values at or above said specified values to prevent color scale washout (e.g. if a few observations are extremely high to the point where all other values are washed out on the color scale).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
settings_units(
  dataset = dataset,
  var_qt = variable_of_interest_qt,
  cap_value = NA,
  cap_color = "red",
  digits = 2,
  lab_title = "Graph of",
  lab_fill = "Units",
  lab_unit = "units"
)

Arguments

dataset

The dataset which to evaluate

var_qt

Character; The variable of interest within the dataset, in quotation marks

cap_value

Numeric; The value of the color "cap" to be applied

cap_color

Character; The color of values at or above the cap_value.

digits

Numeric; the number of digits to round data labels to.

lab_title

Character; the first portion of the visualization title. It is recommended to adjust this to the type of visualization to be made.

lab_fill

Character; the default unit label for the variable of interest (standalone, e.g. y-axis label of 'Units')

lab_unit

Character; the default unit label for the variable of interest (in context of a sentence, e.g. 'X units')

Value

List of values to be applied to various visualization methods:

lab_title

First portion of the visualization title.

lab_title_val

Shorthand unit description intended to be appended to the title.

lab_subtitle

Information with which varaible was applied, in addition to the minimum and maximum values of the set. Intended to be used as a subtitle or caption.

lab_fill

Full unit description intended to be applied to the fill label (or axis labels).

fill_colors

Colorblind-friendly fill color to be applied to a plot using scale_fill_viridis, colored appropriately based on the variable of interest with matching min & max values if applicable:

  • Default: inferno, with the minimum set to 0

  • PM: plasma, with the minimum set to 0

  • humidity: mako (reversed direction), with the scale having a minimum of 0 and maximum of 100

  • temperature (ºF or ºC): cividis, with no scale minimum or maximum

cap_guide

Legend settings (see guides) for arranging legend order in order to properly arrange values at or above the cap_value, and to set the aesthetics to match cap_color where appropraite.

See Also

Other visualization settings: add_cap(), drop_incomplete(), settings_dt_scale(), settings_shapes()

Examples

1
2
3
4
5
6
7
8
units_results_example <- settings_units(july_api_daily, "pm25_atm", cap_value = 17, cap_color = "green")
ggplot(july_api_daily, aes(x = date, y = site_id, fill = pm25_atm)) +
  geom_tile() +
  labs(
    title = paste(units_results_example$lab_title, units_results_example$lab_title_val),
    fill = units_results_example$lab_fill
  )
remove(units_results_example)

gmcginnis/AirVizR documentation built on Dec. 20, 2021, 11:49 a.m.