| annotate_from_matrix {matrixset} | R Documentation |
Apply functions to a single matrix of a matrixset and store results as annotation
Description
This is in essence apply_row_dfw()/apply_column_dfw(), but with the
results saved as new annotations. As such, the usage is almost identical to
these functions, except that only a single matrix can be used, and must be
specified (matrix specification differs also slightly).
Usage
annotate_row_from_apply(
.ms,
.matrix,
...,
names_prefix = "",
names_sep = "_",
names_glue = NULL,
names_sort = FALSE,
names_vary = "fastest",
names_expand = FALSE
)
annotate_column_from_apply(
.ms,
.matrix,
...,
names_prefix = "",
names_sep = "_",
names_glue = NULL,
names_sort = FALSE,
names_vary = "fastest",
names_expand = FALSE
)
Arguments
.ms |
|
.matrix |
a tidyselect matrix name: matrix name as a bare name or a character. |
... |
expressions, separated by commas. They can be specified in one of the following way:
The expressions can be named; these names will be used to provide names to the results. |
names_prefix, names_sep, names_glue, names_sort, names_vary, names_expand |
See
the same arguments of |
Details
A conscious choice was made to provide this functionality only for
apply_*_dfw(), as this is the only version for which the output dimension
is guaranteed to respect the matrixset paradigm.
On that note, see the section 'Grouped matrixset'.
Value
A matrixset with updated meta info.
Grouped matrixset
In the context of grouping, the apply_*_dfw() functions stack the results
for each group value.
In the case of annotate_*_from_matrix(), a tidyr::pivot_wider() is
further applied to ensure compatibility of the dimension.
The pivot_wider() arguments names_prefix, names_sep, names_glue,
names_sort, names_vary and names_expand can help you control the final
annotation trait names.
See Also
annotate_row()/annotate_column().
Examples
# This is the same example as in annotate_row(), but with the "proper" way
# of doing it
ms <- annotate_row_from_apply(student_results, "failure", mn = mean)