Apply a list of functions to a biomonitoR object

Sometimes it can be useful to apply a list of functions to a biomonitoR object. For example with a properly setted list of functions you can calculate more indices at once.


macro <- read.csv(url(""))

macro.asb <- asBiomonitor(macro)

macro.agg <- aggregatoR(macro.asb)

# creating a list of functions funs

myshan <- function(x)(shannon(x))

mybmwpi <- function(x)(bmwp(x, method = "i"))

mybmwpb <- function(x)(bmwp(x, method = "b"))

funs <- list(shannon = myshan, ibmwp = mybmwpi, bmwp = mybmwpb)

# apply the list of functions on macro.agg

indices <- lapply(funs, function(f) f(macro.agg))

# transform the list indices into a data.frame, indices)

Leave a Reply

Your email address will not be published. Required fields are marked *