stat_funtext: Compute text labels based on user-specified functions

Description Usage Arguments Details Value See Also

View source: R/stat_funtext.R

Description

stat_funtext() is used to compute the facets of ggcorrm plots.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stat_funtext(
  mapping = NULL,
  data = NULL,
  geom = "text",
  position = "identity",
  show.legend = NA,
  inherit.aes = TRUE,
  fun,
  nrow = NULL,
  ncol = NULL,
  squeeze = 0.7,
  byrow = TRUE,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

geom

The geometric object to use display the data

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

fun

One of the following: * a) a function of x and y. * b) an rlang lambda style one-sided formula describing a function of two parameters labeled.x and .y * c) an rlang quosure created with quo() that is evaluated in the context of the data analogous to the mutates argument in tidy_corrm().

The functions in a) and b) are evaluated using the x and ycoordinates of the plot as first and second argument, respectively. The quosure in c) is evaluated in the context of the raw data and may contain x and y.

One outcome of the computation per group is stored in a new column called fun_out that can be accessed in the aesthetics using..fun_out...

nrow

integer - the number of rows for the correlation labels if grouping aesthetics are present (defaults to NULL - automatic setting of nrow).

ncol

integer - the number of columns for the correlation labels if grouping aesthetics are present (defaults to NULL - automatic setting of ncol).

squeeze

numeric between 0 an 1. Proportion of the facet width/height the facet labels are restricted to when multiple labels are present (defaults to 0.7 - labels extend over 70% of the extent of the plot).

byrow

logical. Should the correlation labels in plots with multiple groups be filled by rows (byrow = TRUE) or by columns (byrow = FALSE)? Note that the actual number of rows or columns that are filled with values can be below the specified value of nrow or ncol when less rows/columns than specified are needed to reach the total number of groups. Defaults to TRUE.

...

additional arguments passed to ggplot2::layer().

Details

stat_funtext() evaluates a function, rlang lambda style one-sided formula or a quosure in the context of the data used for plotting and computes positions in the plot using the same nrow/ncol based positioning as stat_corrtext().

Value

An object of class Layer.

See Also

stat_corrtext() for correlation text labels. lotri_funtext() and utri_funtext()


r-link/corrmorant documentation built on Jan. 10, 2021, 7:26 p.m.