Introduction

This is sample report for IBI score calculations of sites collected in 2012.

Import dataset

Set up arguments for later calculation

library(MBSStools)
# Metrics, Index, Benthic Macroinvertebrates, genus
# (generate values then scores)
myIndex <- "MBSS.2005.Bugs"
# Thresholds
thresh <- metrics_scoring
# get metric names for myIndex
(myMetrics.Bugs.MBSS <- as.character(droplevels(unique(thresh[thresh[,"Index.Name"]==myIndex,"MetricName.Other"]))))
##  [1] "ntaxa"      "nept"       "nephem"     "pintol_urb" "pephem"    
##  [6] "nscrape"    "pclimb"     "pchiron"    "pcling"     "ptany"     
## [11] "pscrape"    "pswim"      "pdipt"
# Add Narrative
myBreaks <- c(1:5)
myLabels <- c("Very Poor", "Poor", "Fair", "Good")

Calculate metric values

comb_2012_metric <- metric.values(comb_2012, "bugs",myMetrics.Bugs.MBSS)

Calculate IBI scores and Add Narrative

# SCORE
comb_2012_metric_scores <- metric.scores(comb_2012_metric,myMetrics.Bugs.MBSS, "INDEX.NAME", "STRATA_R", thresh)
# View Results
comb_2012_metric_scores

# Add Narrative
comb_2012_metric_scores$IBI_Nar <- cut(comb_2012_metric_scores$IBI
                                     , breaks=myBreaks
                                     , labels=myLabels
                                     , include.lowest=TRUE
                                     , right=FALSE
                                     , ordered_result=TRUE)
# QC, IBI Numeric vs. Narrative
table(comb_2012_metric_scores$IBI
      , comb_2012_metric_scores$IBI_Nar
      , useNA="ifany")
comb_2012_metric_scores

Table of IBI scores with edited column names

library(dplyr)
ibi_table_select <- comb_2012_metric_scores %>% select(SITE,ntaxa,nept,nephem,pintol_urb,pchiron,pcling)
datatable(ibi_table_select,rownames = F,  options= list(scrollX = TRUE, pageLength = nrow(ibi_table_select), dom='t'), selection = 'none',  
          colnames = c('Site' = 'SITE', 'Number of taxa' = 'ntaxa',
                                               'Number of EPT taxa'='nept','Number of Ephemeroptera taxa'='nephem',
                                               'Percent intolerant urban taxa'='pintol_urb', 
                                               'Percent Chironomidae'='pchiron','Percent Clinger'='pcling'),
          caption = htmltools::tags$caption(
    style = 'caption-side: bottom; text-align: center;',
    'Table 1. Metric values and IBI scores from benthos sites collected in 2012 in Red Run')
  )

Note: Percent Chironomidae are incorrectly calculated by the MBSStools package.