dplyr-verbs {ordr} | R Documentation |
dplyr verbs for tbl_ord factors
Description
These functions adapt dplyr verbs to the factors of a tbl_ord.
The raw verbs are not defined for tbl_ords; instead, each verb
has two analogues, corresponding to the two matrix factors. They each rely
on a common workhorse function, which takes the composition of the
dplyr verb with annotation_*
, applied to the factor, removes any
variables corresponding to coordinates or already annotated, and only then
assigns it as the new "*_annotation"
attribute of .data
(see
annotation). Note that these functions are not generics and so cannot be
extended to other classes.
Usage
pull_factor(.data, var = -1, .matrix)
pull_rows(.data, var = -1)
pull_cols(.data, var = -1)
rename_rows(.data, ...)
rename_cols(.data, ...)
select_rows(.data, ...)
select_cols(.data, ...)
mutate_rows(.data, ...)
mutate_cols(.data, ...)
transmute_rows(.data, ...)
transmute_cols(.data, ...)
cbind_rows(.data, ..., elements = "all")
cbind_cols(.data, ..., elements = "all")
left_join_rows(.data, ...)
left_join_cols(.data, ...)
Arguments
.data |
An object of class 'tbl_ord'. |
var |
A variable specified as in |
.matrix |
A character string partially matched (lowercase) to several
indicators for one or both matrices in a matrix decomposition used for
ordination. The standard values are |
... |
Comma-separated unquoted expressions as in, e.g.,
|
elements |
Character vector; which elements of each factor for which to
render graphical elements. One of |
Value
A tbl_ord; the wrapped model is unchanged.
Examples
# illustrative ordination: LDA of iris data
(iris_lda <- ordinate(iris, cols = 1:4, lda_ord, grouping = iris$Species))
# extract a coordinate or annotation
head(pull_rows(iris_lda, Species))
pull_cols(iris_lda, LD2)
# rename an annotation
rename_cols(iris_lda, species = name)
# select annotations
select_rows(iris_lda, species = name, .element)
# create, modify, and delete annotations
mutate_cols(iris_lda, vec.length = sqrt(LD1^2 + LD2^2))
transmute_cols(iris_lda, vec.length = sqrt(LD1^2 + LD2^2))
# bind data frames of annotations
iris_medians <-
stats::aggregate(iris[, 1:4], median, by = iris[, 5, drop = FALSE])
iris_lda %>%
# retain '.element' in order to match by `elements`
select_rows(.element) %>%
cbind_rows(iris_medians, elements = "active")