taxonomy()
or taxmap()
R/taxonomy--docs.R
sample_frac_taxa.Rd
Randomly sample some proportion of taxa from a taxonomy()
or taxmap()
object. Weights can be specified for taxa or the observations assigned to
them. See
dplyr::sample_frac()
for the inspiration for this function.
obj$sample_frac_taxa(size, taxon_weight = NULL, obs_weight = NULL, obs_target = NULL, use_subtaxa = TRUE, collapse_func = mean, ...) sample_frac_taxa(obj, size, taxon_weight = NULL, obs_weight = NULL, obs_target = NULL, use_subtaxa = TRUE, collapse_func = mean, ...)
obj | ( |
---|---|
size | ( |
taxon_weight | ( |
obs_weight | ( |
obs_target | ( |
use_subtaxa | ( |
collapse_func | ( |
... | Additional options are passed to |
An object of type taxonomy()
or taxmap()
Other taxmap manipulation functions:
arrange_obs()
,
arrange_taxa()
,
filter_obs()
,
filter_taxa()
,
mutate_obs()
,
sample_frac_obs()
,
sample_n_obs()
,
sample_n_taxa()
,
select_obs()
,
transmute_obs()
# sample half of the taxa sample_frac_taxa(ex_taxmap, 0.5, supertaxa = TRUE)#> <Taxmap> #> 13 taxa: b. Mammalia, c. Plantae ... p. sapiens, r. tuberosum #> 13 edges: NA->b, NA->c, b->d, b->e ... g->l, j->o, k->p, l->r #> 4 data sets: #> info: #> # A tibble: 6 x 4 #> taxon_id name n_legs dangerous #> <chr> <chr> <dbl> <lgl> #> 1 d tiger 4 TRUE #> 2 i cat 4 FALSE #> 3 o mole 4 FALSE #> # … with 3 more rows #> phylopic_ids: a named vector of 'character' with 6 items #> d. e148eabb-f138-43[truncated] ... r. 63604565-0406-46[truncated] #> foods: a list of 6 items named by taxa: #> d, i, o, p, l, r #> abund: #> # A tibble: 8 x 5 #> taxon_id code sample_id count taxon_index #> <chr> <fct> <fct> <dbl> <int> #> 1 d T A 1 1 #> 2 i C A 2 2 #> 3 o M B 5 3 #> # … with 5 more rows #> 1 functions: #> reaction