Description Usage Arguments Details Value See Also Examples
lotri_funtext()
and utri_funtext()
are used to display
user-specified text labels in the off-diagonal facets of ggcorrm plots.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
fun |
One of the following: * a) a function of The functions in a) and b) are evaluated using the One outcome of the computation per group is stored in a new column called
|
mapping |
Set of aesthetic mappings created by aes(). x
and y are set automatically and must not bechanged, but all other
aesthetics may be manipulated. By default, the |
nrow |
integer - the number of rows for the correlation labels if
grouping aesthetics are present (defaults to |
ncol |
integer - the number of columns for the correlation labels if
grouping aesthetics are present (defaults to |
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 ( |
show.legend |
logical. Should this layer be included in the legends? FALSE (the default) never includes, TRUE always includes, and NA includes only if aesthetics are mapped. It can also be a named logical vector to finely select the aesthetics to display. |
... |
Additional arguments to stat_funtext. |
lotri_funtext()
and utri_funtext()
can be used to display user-
defined text labels in the lower or upper triangular facets of
ggcorrm
plots, respectively. The functions can be evaluated separately
for different groups by using grouping aesthetics such as aes(color = group)
.
If fun
is a function or rlang lambda-style one-sided formula,
it is called on the data in each group using the x
coordinate as first and the y
coordinate as second argument. If fun
is a quosure, it is evaluated in the
context of the data in the respective group.
lotri_funtext()
and utri_funtext()
are wrappers around
stat_funtext()
that additionally take care of the right specification of
aesthetics. The positioning of the labels in stat_funtext()
follows the
same rules as in stat_corrtext()
.
A ggplot2
layer with text labels for user_specified functions.
stat_funtext
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
if(interactive()){
# function to compute linear model slopes
lmslope <- function(y, x) round(coef(lm(y ~ x))[2], 2)
# add slopes using a function
ggcorrm(drosera, rescale = "as_is") +
lotri(geom_point(alpha = 0.4)) +
utri_funtext(fun = lmslope) +
dia_density(fill = "steelblue", lower = .4) +
dia_names(y_pos = .1)
# compute Pearson correlations as a lambda expression (top)
# and as a quosure(bottom)
ggcorrm(drosera, rescale = "as_is") +
utri_funtext(fun = ~ round(cor(.x, .y), 3)) +
lotri_funtext(fun = quo(round(cor(x, y), 3))) +
dia_names(y_pos = .5)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.