# Processing a Dose Response Curve Using R library(drc) # Dose Response Curve Package--must be downloaded separately import <- read.csv(file.choose()) names(import) # Shows the name of the variables control <- subset(import,Treat=="C") #Brute force to create separate date.frames test <- subset(import,Treat=="I") plot(control$ATP,control$PI, col="Blue", ylim=c(0,120), xlab="mM ATP", ylab="Pi (mM)") points(test$ATP,test$PI, col="Red", pch="X") #Creates a plot and overlay of data # Below use the package that must be loaded installed from wehsite and installed model_AR3 <- drm(PI~ATP, Treat, data=import, fct=AR.3(), pmodels=list(~1, ~factor(Treat), ~factor(Treat))) # Function Creates Model #Not sure which model to pick so I picked AR.3 because it was used in other examples. summary(model_AR3) #summarize statistical tests--help help(AR.3) to figure out what it means plot(model_AR3, legendPos=c(0.2,110)) # Legend is in the way, so I used legendPos to move it, see help(plot.drc) #Below is a short intro to R... # Introduction to R ESSP 250 # the pound sign if for comments... # getting data in by typing data1 <- data.frame() fix(data1) # Yes, closing the window is okay, the data is already saved # importing comma separated values import<- read.csv(file.choose()) #File.choose opens a broswer window--pretty cool! # existing data help(InsectSprays) data(InsectSprays) names(InsectSprays) # means and standard deviations mean(InsectSprays$count) # The dollar sign is used to select the vector inside the data.frame sd(InsectSprays$count) # view the data, beat excel ANYDAY, where boxplots are an absolute nightmare to format boxplot(count ~ spray, data = InsectSprays, xlab = "Type of spray", ylab = "Insect count", main = "Insect Sprays Results", varwidth = TRUE, col = "lightgray") # Analysis of Variance fm1 <- aov(count ~ spray, data = InsectSprays) summary(fm1) opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) plot(fm1) fm2 <- aov(sqrt(count) ~ spray, data = InsectSprays) summary(fm2) plot(fm2) par(opar) # Regression Example plot(co2, ylab = expression("Atmospheric concentration of CO"[2]), las = 1) title(main = "Mauna Loa Atmospheric CO2 Concentration") carbon <- lm(co2 ~ 1, data=co2) carbon data(airquality) names(airquality) airquality plot(Ozone~Temp, data=airquality) lm1 <- lm(Ozone ~ Temp, data=airquality) summary(lm1) plot(lm1) plot(Ozone~Temp, data=airquality) abline(lm1) airquality$Temp2 <- airquality$Temp^2 lm2 <- lm(Ozone ~ Temp2 + Temp, data=airquality) summary(lm2) plot(lm2) AIC(lm1,lm2)