here is the entire code for the last error:
#phytoplankton
library(readxl)
snails <- read_excel("Applied_Ecology_Activity _1/phytoplankton.xlsx")
View(phytoplankton)
#calculate the mean phytoplankton by tank
mean_by_tank = aggregate(Phytoplankton_Fluorescence ~ Tank + Treatment_Code, data=phytoplankton, mean)
mean_by_tank
#calculate the mean phytoplankton by treatment
mean_by_trt = aggregate(Phytoplankton_Fluorescence ~ Treatment_Code, data=mean_by_tank, mean)
mean_by_trt
#Standard Error function
st.err <- function(x) {
sd(x)/sqrt(length(x))
}
#Calculate the standard error of the mean phytoplankton by tank
SE <- aggregate(Phytoplankton_Fluorescence ~ Treatment_Code, data=mean_by_tank, st.err)
SE
#combine the data to put into one table
mean_by_trt$SE = SE$Phytoplankton_Fluorescence
mean_by_trt
#plotting library
library(ggplot2)
#define the standard error limits for the creation of the error bars
ymax = mean_by_trt$Phytoplankton_Fluorescence + mean_by_trt$SE
ymin = mean_by_trt$Phytoplankton_Fluorescence - mean_by_trt$SE
#create plot (p) of the mean Number Phytoplankton by treatment with standard error bars
p = ggplot(mean_by_tank, aes(fill=Treatment_Code, y=Phytoplankton_Fluorescence, x=Tank))
p + geom_bar(position=position_dodge(), stat="identity", colour='black') +
geom_errorbar(aes(ymin=ymin, ymax=ymax), width=.2,position=position_dodge(.9)) +
xlab("Species") +
ylab("Relative Phytoplankton Fluorescence") +
scale_fill_discrete(name= "Treatment", labels = c("natives", "bullfrog", "mosquitofish", "bullfrog + mosquitofish"))