add_metadata | R Documentation |
This function combines two tables based on the row identifiers.
add_metadata(x, metad, xid = NULL, mid = NULL, drop_mid = T)
x |
Data frame with data of interest |
metad |
Data frame with metadata that should be added; or phyloseq object with sample_data slot |
xid |
Character, name of the column with row identifiers in the main data (x) |
mid |
Character, name of the column with row identifiers in the metadata (metad) |
drop_mid |
Logical; if TRUE (default), metadata identifiers will be removed from results |
Data frame
# Load data
data(GlobalPatterns)
# As an example, estimate richness
div <- estimate_richness(GlobalPatterns, measures = c("Observed", "Shannon"))
div <- dfRowName(div, name = "SampleID")
# Take metadata from phyloseq object
div1 <- add_metadata(div, metad = GlobalPatterns, xid = "SampleID", mid = "X.SampleID")
head(div1)
# Or metadata from data frame
metad <- as(sample_data(GlobalPatterns), "data.frame")
div2 <- add_metadata(div, metad = metad, xid = "SampleID", mid = "X.SampleID")
head(div2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.