bdply | R Documentation |
blply()
and bdply()
let you divide your biom dataset into smaller
pieces, run a function on those smaller rbiom objects, and return the
results as a data.frame or list.
bdply(biom, vars, FUN, ..., iters = list(), prefix = FALSE)
blply(biom, vars, FUN, ..., iters = list(), prefix = FALSE)
biom |
An rbiom object, such as from |
vars |
A character vector of metadata fields. Each unique combination
of values in these columns will be used to create a subsetted
rbiom object to pass to |
FUN |
The function to execute on each subset of |
... |
Additional arguments to pass on to |
iters |
A named list of values to pass to |
prefix |
When |
You can also specify additional variables for your function to iterate over in unique combinations.
Calls plyr::ddply()
or plyr::dlply()
internally.
For bdply()
, a tibble data.frame comprising the accumulated
outputs of FUN
, along with the columns specified by
vars
and iters
. For blply()
, a named list that has details
about vars
and iters
in attr(,'split_labels')
.
Other metadata:
glimpse.rbiom()
Other biom:
biom_merge()
library(rbiom)
bdply(hmp50, "Sex", `$`, 'n_samples')
blply(hmp50, "Sex", `$`, 'n_samples') %>% unlist()
bdply(hmp50, c("Body Site", "Sex"), function (b) {
adm <- adiv_matrix(b)[,c("Shannon", "Simpson")]
apply(adm, 2L, mean)
})
iters <- list(w = c(TRUE, FALSE), d = c("bray", "euclid"))
bdply(hmp50, "Sex", iters = iters, function (b, w, d) {
r <- range(bdiv_distmat(biom = b, bdiv = d, weighted = w))
round(data.frame(min = r[[1]], max = r[[2]]))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.