Apply a function to data for the observations for each taxon. This is similar
to using obs()
with lapply()
or sapply()
.
obj$obs_apply(data, func, simplify = FALSE, value = NULL, subset = NULL, recursive = TRUE, ...) obs_apply(obj, data, func, simplify = FALSE, value = NULL, subset = NULL, recursive = TRUE, ...)
obj | The |
---|---|
data | Either the name of something in |
func | ( |
simplify | ( |
value | What data to give to the function. This is usually the name of
column in a table in |
subset | Taxon IDs, TRUE/FALSE vector, or taxon indexes to use.
Default: All taxa in |
recursive | ( |
... | Extra arguments are passed to the function. |
# Find the average number of legs in each taxon obs_apply(ex_taxmap, "info", mean, value = "n_legs", simplify = TRUE)#> [1] 3.5 0.0 4.0 2.0# One way to implement `n_obs` and find the number of observations per taxon obs_apply(ex_taxmap, "info", length, simplify = TRUE)#> [1] 4 2 1