apply_by_groups: Apply by groups

Description Usage Arguments Value Examples

Description

Apply a function to samples from a metadata's variable.

Usage

1
2
apply_by_groups(dataset, metadata.var, fn.to.apply = "mean", 
variables = NULL, variable.bounds = NULL)

Arguments

dataset

list representing the dataset from a metabolomics experiment.

metadata.var

name of the metadata's variable.

fn.to.apply

function to apply (e.g. mean, max, min).

variables

allows to define which variables to calculate the stats (if numbers, indexes are assumed).

variable.bounds

allow to define an interval of variables (if numeric).

Value

Returns a vector with the variables and the value of the applied function on the metadata's groups.

Examples

1
2
3
4
     ## Example of applying a function to groups
	 library(specmine.datasets)
     data(cachexia)
     apply.groups.result = apply_by_groups(cachexia, "Muscle.loss", mean)

specmine documentation built on Sept. 21, 2021, 5:06 p.m.