R code for CicadaRWL vs Mass
Jump to navigation
Jump to search
ctable<-read.delim("cicadaPreySpeciesWithIndicators.txt") CicadaMass<-ctable[,1] CicadaRWL<-ctable[,2] lnCicadaMass <-ctable[,3] lnCicadaRWL <-ctable[,4] small<-ctable[,5] medium<-ctable[,6] large<-ctable[,7] mediumCross <-medium*lnCicadaRWL largeCross <-large*lnCicadaRWL lm3 <- lm(lnCicadaMass ~ lnCicadaRWL + medium) summary(lm3) coefs <- coef(lm3) coefs jpeg(filename = "FinalCicadaRWLvsMassFittedPlot.jpeg") plot(CicadaRWL, CicadaMass, main = "Body Size Relationships of Cicadas", xlab="Cicadas RWL (mm)", ylab="Cicadas Wet Mass (mg)", pch = 20) xCoord1 <- c(23.56:30.16) points(xCoord1, exp(coefs[1])*xCoord1^(coefs[2]), type="l", lwd=3, col="red") xCoord2 <- c(40.31:46.23) points(xCoord2, exp(coefs[1]+coefs[3])*xCoord2^(coefs[2]), type="l", lwd=3, col="blue") xCoord3 <- c(48.12:55.68) points(xCoord3, exp(coefs[1])*xCoord3^(coefs[2]), type="l", lwd=3, col="red") colors <- c("red", "blue") legend("topleft", c("Small, Large y = 0.017x^3.02", "Medium y = 0.02x^3.02"), fill=colors, bty="n")