Sample n taxa from
sample_n_taxa(.data, size, taxon_weight = NULL, obs_weight = NULL, use_subtaxa = TRUE, collapse_func = mean, ...)
taxmap) The object to sample from.
numericof length 1) The number of taxa to sample.
numeric) Non-negative sampling weights of each taxon. The expression given is evaluated in the context of
taxon_data. In other words, any column name that appears in
taxon_data(.data)can be used as if it was a vector on its own. If
obs_weightis also specified, the two weights are multiplied (after
obs_weightfor each taxon is calculated).
numeric) Sampling weights of each observation. The weights for each observation assigned to a given taxon are supplied to
collapse_functo get the taxon weight. If
TRUEthen the observations assigned to every subtaxa are also used. The expression given is evaluated in the context of
obs_data. In other words, any column name that appears in
obs_data(.data)can be used as if it was a vector on its own. If
taxon_weightis also specified, the two weights are multiplied (after
obs_weightfor each observation is calculated).
logicalof length 1) Affects how the
obs_weightoption is used. If
TRUE, the weights for each taxon in an observation's classification are multiplied to get the observation weight. Otherwise, just the taxonomic level the observation is assign to it considered.
functionof length 1) If
taxon_weightis used and
TRUE, the weights for each taxon in an observation's classification are supplied to
collapse_functo get the observation weight. This function should take numeric vector and return a single number.
- Additional options are passed to
An object of type
Other dplyr-like functions:
# subsample taxa, preserving shared supertaxa sample_n_taxa(unite_ex_data_3, 100, supertaxa = TRUE) # subsample taxa using weights, preserving subtaxa sample_n_taxa(unite_ex_data_3, 10, subtaxa = TRUE, taxon_weight = ifelse(unite_rank == "g" & n_subtaxa > 3, 1, 0))
Looks like there are no examples yet.