freq.cols: Get color palette depending on frequencies within data of...

View source: R/freq_cols.R

freq.colsR Documentation

Get color palette depending on frequencies within data of given set of colors

Description

This function uses a given set of colors and frequencies of them within given dataset and range to derive a set of a given number of colors fitting with the inputted frequencies.

Usage

freq.cols(cols, ncols, freqs, lims, type, values)

Arguments

cols

The vector of colors to be resized given data and frequencies

ncols

The number of desired colors for the new vector of colors with adjusted color proportions

freqs

The inputted frequencies of the colors. Can be a character ("equal" or "even", but actually any character, giving equal frequencies to all colors) or a numeric (specifying proportions or bounds to use)

lims

The limits to use to compute bounds (and then adjusted frequencies) for each color. Set by default to the range of values

type

If specifying proportions to freqs, whether they represent fractions of the width between lims (type="width") or real proportions of the population of values (type="proportion")

values

If type="proportion", the data to use to get the real population proportions and then the adjusted color frequencies

Details

This function mainly relies on discrete.palette to resize the inputted colors taking into account their frequencies. The frequencies freqs can be given explicitly (if specifying numeric values), otherwise they are considered to be all equal (if specifying a character). Numeric frequencies can be either proportions or bounds between lims. In both cases, they depend on a given set of values and on limits lims to consider (by default the range of the dataset). If frequencies are proportions, they are converted to bounds to determine the effective width between them (or to one of the limits) relative to the inter-limits width. Hence, bounds can also be directly provided, if known. Such relative widths then serve as the freqs argument of discrete.palette. If proportions are provided (explicit numeric or just character), it is also possible to say with type whether these proportions are between-limits width proportion or values population proportion. In the latter case, quantiles corresponding to the given frequencies freqs are hence used as bounds. The output will use adjusted frequencies (given the inputted one and the width/proportion choice if applicable) to resize the inputed colors cols as a new vector of colors of size ncols


jacobmaugoust/ULT documentation built on May 16, 2023, 1:29 p.m.