This is sample report for a randomization test on the weighted mean tolerance values of lost taxa in Red Run. Taxa include all families, orders, and genera. However, Chironomidae and Oligochaeta were excluded due to taxonomic bias and high abundance.
library(readxl)
b1wtv <- read_excel("C:/Users/tiena/OneDrive - Towson University/Thesis stuff/Data Analysis/Part a (1987 vs 2009)/Lost and Gained/Randomization of weighted tolval/Data (no Chirae and Oligta).xlsx",
sheet = "B1")
set.seed(1)
sample_stats <- function(df, n=23){
df <- df[sample(1:nrow(df), n, replace=F),]
mx1 <- sum(df$TV*df$Density)/sum(df$Density)
return(c(mx1))
}
(sample_stats(b1wtv))
results <- replicate(10000, sample_stats(b1wtv,n=23))
## [1] 0.7287