Description Usage Arguments Value See Also Examples
View source: R/settings_units.R
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).
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"
)
|
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 |
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') |
List of values to be applied to various visualization methods:
First portion of the visualization title.
Shorthand unit description intended to be appended to the title.
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.
Full unit description intended to be applied to the fill label (or axis labels).
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
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.
Other visualization settings:
add_cap()
,
drop_incomplete()
,
settings_dt_scale()
,
settings_shapes()
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.