bin_color_continuous: Bin data and get corresponding colors.

Description Usage Arguments Details Value Examples

Description

Bins data for according to a given list.

Usage

1
2
bin_color_continuous(data, by, range, bins, scale = NULL, ascending = TRUE,
  bin_name = "bins")

Arguments

data

The data to bin. Generally a data table.

by

Character; The name of of our output column that we are binning.

range

A vector of length two that defines the max and min value of the scale.

bins

Vector; Either a number indicating the number of bins, or a vector containing the locations where the bins should be cut.

scale

List; should be length 4, in the format c(lowest, midpoint (white), one-bin-above-midpoint, highest).

ascending

logical; do increasing values indicate a positive trend?

bin_name

Character; Name of column to be created that contains bin data

Details

Currently provides scales and colors for reliability, safeyield, resilience, and vulnerability. To access, use metric="reliability", metric="safeyield", etc.

Value

a list x. x$data returns the data frame with a new column containing the bins, x$colors contains the corresponding color scale.

Examples

1
2
3
4
## Not run: df <- expand.grid(temp = 0:8, precip = seq(0.7, 1.3, by = 0.1))
df$rel <- seq(40, 100, length=63)
df2 <- bin_color_continuous(df, by = "rel", metric = "reliability")
## End(Not run)

tbadams45/wrviz documentation built on May 31, 2019, 3:58 a.m.