Learn R Programming

specmine (version 1.0)

apply_by_group: Apply by group

Description

Apply a function to samples from a given metadata's group.

Usage

apply_by_group(dataset, fn.to.apply, metadata.var, var.value)

Arguments

dataset
list representing the dataset from a metabolomics experiment.
fn.to.apply
function to apply (e.g. mean, max, min).
metadata.var
name of the metadata's variable.
var.value
value of the metadata's variable.

Value

Returns a vector with the variables and the value of the applied function.

Examples

Run this code
     ## Example of applying a function to a group
     data(cachexia)
     apply.group.result = apply_by_group(cachexia, mean, "Muscle.loss", 
			  "control")

Run the code above in your browser using DataLab