| apply_by_group | R Documentation |
Applies a function to the variables of samples belonging to a given group.
apply_by_group(dataset, fn.to.apply, metadata.var, var.value)
dataset |
Dataset to analyze. |
fn.to.apply |
Function to apply. |
metadata.var |
Metadata variable used to define the group. |
var.value |
Value or values of the metadata variable to select. |
A named vector or matrix, depending on the output of 'fn.to.apply', containing the values obtained by applying the function to each variable across the samples belonging to the selected group.
data <- matrix(
c(1, 2, 3, 4, 5, 6),
nrow = 2,
dimnames = list(c("x1", "x2"), c("s1", "s2", "s3"))
)
metadata <- data.frame(
group = c("control", "control", "case"),
row.names = c("s1", "s2", "s3")
)
dataset <- list(data = data, metadata = metadata)
apply_by_group(dataset, mean, "group", "control")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.