An official website of the United States government.

This is not the current EPA website. To navigate to the current EPA website, please go to www.epa.gov. This website is historical material reflecting the EPA website as it existed on January 19, 2021. This website is no longer updated and links to external websites and some internal pages may not work. More information »

CADDIS Volume 4

R Script: Compute Weighted-Average Tolerance Values

# Script to compute WA tolerance values

WA <- rep(NA, times = length(taxa.names))
            # Define a WA to be vector of
            # length the same as the
            # number of taxa of interest

for (i in 1:length(taxa.names)) {
  WA[i] <- sum(dfmerge[,taxa.names[i]]*dfmerge$temp)/
   sum(dfmerge[,taxa.names[i]])
}
names(WA) <- taxa.names
print(WA)