# load data data <- read.csv("MushroomHunt2 threshold-table-2.csv", sep = ",") ## calculate mosquito numbers per sampling day #for (i in 1:length(MOSQ$AeVex)) { # MOSQ$AeVexDay[[i]] <- MOSQ$AeVex[[i]]/MOSQ$SamplingDays[[i]] #} #for (i in 1:length(MOSQ$OcSti)) { # MOSQ$OcStiDay[[i]] <- MOSQ$OcSti[[i]]/MOSQ$SamplingDays[[i]] #} vec.critical.time <- c(1:50) data.avg <- matrix(ncol = 1, nrow = length(vec.critical.time)) data.std <- matrix(ncol = 1, nrow = length(vec.critical.time)) for (i in 1:length(vec.critical.time)) { data.vec <- data[data$critical.time == vec.critical.time[[i]],] data.avg[i] <- mean(data.vec$prop.mushrooms.found) data.std[i] <- sd(data.vec$prop.mushrooms.found) } plot(vec.critical.time, data.avg, type = "l", xlab = "critical.time", ylab = "prop.mushrooms.found", col = "blue", ylim = c(0,1)) for (i in 1:length(vec.critical.time)) { lines(c(vec.critical.time[i], vec.critical.time[i]),c(data.avg[i]-data.std[i], data.avg[i]+data.std[i]), col = "green") }