taxonomy()
or taxmap()
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, ...)
(taxonomy()
or taxmap()
) The object to sample from.
(numeric
of length 1) The proportion of taxa to sample.
(numeric
) Non-negative sampling weights of each
taxon. If obs_weight
is also specified, the two weights are
multiplied (after obs_weight
for each taxon is calculated).
(numeric
) This option only applies to taxmap()
objects. Sampling weights of each observation. The weights for each
observation assigned to a given taxon are supplied to collapse_func
to
get the taxon weight. If use_subtaxa
is TRUE
then the observations
assigned to every subtaxa are also used. Any variable name that appears in
all_names()
can be used as if it was a vector on its own. If
taxon_weight
is also specified, the two weights are multiplied (after
obs_weight
for each observation is calculated). obs_target
must be used
with this option.
(character
of length 1) This option only applies to
taxmap()
objects. The name of the data set in obj$data
that values in
obs_weight
corresponds to. Must be used when obs_weight
is used.
(logical
or numeric
of length 1) Affects how the
obs_weight
option is used. If TRUE
, the weights for each taxon in an
observation's classification are multiplied to get the observation weight.
If TRUE
just the taxonomic level the observation is assign to it
considered. Positive numbers indicate the number of ranks below the target
taxa to return. 0
is equivalent to FALSE
. Negative numbers are
equivalent to TRUE
.
(function
of length 1) If taxon_weight
is
used and supertaxa
is TRUE
, the weights for each taxon in an
observation's classification are supplied to collapse_func
to get
the observation weight. This function should take numeric vector and
return a single number.
Additional options are passed to filter_taxa()
.
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()
# NOT RUN {
# sample half of the taxa
sample_frac_taxa(ex_taxmap, 0.5, supertaxa = TRUE)
# }
Run the code above in your browser using DataCamp Workspace