#' Compute D18 IBI
#'
#' Computes D18 IBI score and QC.
#'
#' @param data User data merged with metadata, as generated by \code{\link{taxonInfo}}
#' @param all If false (default), return only SampleID, D18 IBI and QC. Else, all metrics are returned.
#
#' @export
#' @examples
#' data(algaeSamples)
#' preparedData <- taxonInfo(validator(algaeSamples))
#' D18(preparedData$cleanData)
D18 <- function(data, all=FALSE){
metrics <- dia.metrics(data)
calcD18(metrics, all)
}
calcD18 <- function(metrics, all=FALSE){
metrics$D18 <- 10*rowMeans(metrics[,c("SCALED.sed.tol.high","SCALED.low.P",
"SCALED.N.het","SCALED.DO.50","SCALED.halo")])
metrics$D18.QCmin<- apply(metrics[,c("QC.sed.tol.PropValvesWithTraits",
"QC.Ptrait.PropValvesWithTraits",
"QC.N.het.PropValvesWithTraits",
"QC.DO.PropValvesWithTraits",
"QC.halo.PropValvesWithTraits")],
1, min)
if(all){
metrics
} else {
metrics[, c("SampleID", "D18", "D18.QCmin")]
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.