add_cap: Cap a Numeric Variable

Description Usage Arguments Value See Also Examples

View source: R/add_cap.R

Description

Apply a cap value of a specified color to numeric variables, either by replacing them with 'NA', or flagging them in a new column.

Usage

1
add_cap(dataset, var_qt, cap_value, cap_color, type = "filter")

Arguments

dataset

Data set for which to apply the cap to

var_qt

Character; the variable of interest (in quotation marks) for which to apply the cap

cap_value

Numeric; the value of the specified variable (var_qt) at and above to be capped

cap_color

Character; the color which will be applied to values at or above cap_value

type

Character choice: "filter" or "flag"; the former will replace values at or above cap_value with 'NA', while the latter will add a logical column ("above_cap") for if the respective row's value is at or above the cap_value.

Value

Series of visualization options to apply a discrete color cap to a continuous variable:

dataset

Dataset with the values at or above the cap value either replaced with 'NA's or flagged (see type argument above).

lab_subtitle_cap

Character value which will include information of the cap value and color.

cap_guide

Guide (see guides) containing fill and color arguments to allow the color cap to remain seprate in the legend.

See Also

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

Examples

1
2
3
4
example_cap_results <- add_cap(july_api_daily, "pm25_atm", cap_value = 15, cap_color = "red")
ggplot(july_api_daily, aes(date, pm25_atm)) +
  labs(subtitle = example_cap_results$lab_subtitle_cap)
remove(example_cap_results)

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