ScaleSimple: Default implementation of Scale objects

Description Super class Methods

Description

Most useful scales will inherit from ScaleContinuous or ScaleDiscrete, both of which use the scales package to create meaningful mappings between user data and aesthetics with useful breaks and labels.

Super class

ggr6::Scale -> ScaleSimple

Methods

Public methods

Inherited methods

Method new()

Usage
ScaleSimple$new(aesthetics = character(0))

Method is_empty()

Usage
ScaleSimple$is_empty()
Details

Returns TRUE if the scale has $limits() (or can calculate them).


Method transform()

Usage
ScaleSimple$transform(x)

Method untransform()

Usage
ScaleSimple$untransform(x)

Method transform_tbl()

Usage
ScaleSimple$transform_tbl(data)

Method untransform_tbl()

Usage
ScaleSimple$untransform_tbl(data)

Method train()

Usage
ScaleSimple$train(x)

Method train_tbl()

Usage
ScaleSimple$train_tbl(data_trans)

Method reset()

Usage
ScaleSimple$reset()

Method map_tbl()

Usage
ScaleSimple$map_tbl(data_trans)

Method breaks()

Usage
ScaleSimple$breaks()

Method breaks_minor()

Usage
ScaleSimple$breaks_minor()
Details

Calculates and returns minor breaks in transformed data space. This can be a function of the $breaks(), $limits(), and number of intervals between breaks (usually 2). Minor breaks usually don't make sense for discrete scales.


Method labels()

Usage
ScaleSimple$labels()
Details

Calculates and returns the labels associated with the $breaks(). This can be a function of the $breaks(), and by default the $format() method of the transform is used.


Method limits()

Usage
ScaleSimple$limits()
Details

Calculates and returns the limits. This can be a funnction of the $trained_range(), and defaults to returning the $trained_range(). Continuous limits are always a numeric vector of length 2; discrete limits are usually a character vector containing possible values.


Method trained_range()

Usage
ScaleSimple$trained_range()
Details

The range of the values in transformed data space that were observed for this scale's aesthetics. Contiuous ranges are always NULL (when no values were observed) or a numeric vector of length 2; discrete ranges are usually a character vector of values that were observed in the data.


Method set_breaks()

Usage
ScaleSimple$set_breaks(breaks)
Details

Set the breaks for this scale. Can be a vector of breaks in user data space or a function of the $limits().


Method set_breaks_minor()

Usage
ScaleSimple$set_breaks_minor(breaks_minor)
Details

Set the minor breaks for this scale. Can be a vector of breaks in user data space or a function of the $breaks(), $limits(), and the number 2.


Method set_labels()

Usage
ScaleSimple$set_labels(labels)
Details

Set the labels for this scale. Can be a vector of labels or a function of the $breaks().


Method set_limits()

Usage
ScaleSimple$set_limits(limits)
Details

Set the limits for this scale. Can be a function of the $trained_range() or a vector (length 2 numeric for continuous scales or a character vector for discrete scales). @details Set the out-of-bounds function for this scale. The out-of-bounds function is a function of a vector and the $limits(); useful oob functions include oob_keep() (which does nothing; the default), scales::censor() (which sets values outside the limits to NA) and scales::squish() (which sets values outside the limits to the outermost values), and censor_discrete() (which works like scales::censor() but works for discrete scales).


Method set_oob()

Usage
ScaleSimple$set_oob(oob)

Method set_range()

Usage
ScaleSimple$set_range(range)
Details

Set the range class for this scale. This must be a subclass of scales::Range.


Method set_rescaler()

Usage
ScaleSimple$set_rescaler(rescaler)
Details

Set the rescaler function for this scale. Rescaled values (between 0 and 1) are often useful as inputs to continuous palletes. This function should take a keyword argument from, which is the scale $limits(). The most useful values for rescaler are rescale_none() (the default) and scales::rescale().


Method set_trans()

Usage
ScaleSimple$set_trans(trans)
Details

Set the transform for this scale. See scales::trans_new() for a list of transforms for continuous scales. For discrete scales, the default value of discrete_identity_trans() is probably the only value that makes sense.


Method set_na_value()

Usage
ScaleSimple$set_na_value(na_value)
Details

Set the output (mapped data space) value that will represent NA values for this scale.


Method set_limits_empty()

Usage
ScaleSimple$set_limits_empty(limits_empty)
Details

Set the limits to return (in transformed data space) when $is_empty() returns TRUE.


Method clone()

The objects of this class are cloneable with this method.

Usage
ScaleSimple$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


paleolimbot/ggr6 documentation built on Feb. 5, 2020, 2:17 p.m.