# Load the CO2 Dataset Now! Answer the questions below.
# Carbon Dioxide Uptake in Grass Plants ####
# The CO2 dataframe is from an experiment on the cold tolerance of the
# grass species Echinochloa crus-galli. The CO2 uptake of six plants
# from Quebec and six plants from Mississippi was measured at
# several levels of ambient CO2 concentration. Half the plants
# of each type were chilled overnight before the experiment.
data("CO2")
head(CO2)## Plant Type Treatment conc uptake
## 1 Qn1 Quebec nonchilled 95 16.0
## 2 Qn1 Quebec nonchilled 175 30.4
## 3 Qn1 Quebec nonchilled 250 34.8
## 4 Qn1 Quebec nonchilled 350 37.2
## 5 Qn1 Quebec nonchilled 500 35.3
## 6 Qn1 Quebec nonchilled 675 39.2
# Important Note: R thinks that the Plant, Type, and Treatment
# columns contain text. Don't forget the quotation marks around
# "text" when subsetting in your homework. # no it does not contain missing data. And it is important to check for missing data that way we can exclude it from our selection.HINT: the | symbol means ‘or’. This may be useful in your answer!
head (CO2) #code and **first six lines of output** ## Plant Type Treatment conc uptake
## 1 Qn1 Quebec nonchilled 95 16.0
## 2 Qn1 Quebec nonchilled 175 30.4
## 3 Qn1 Quebec nonchilled 250 34.8
## 4 Qn1 Quebec nonchilled 350 37.2
## 5 Qn1 Quebec nonchilled 500 35.3
## 6 Qn1 Quebec nonchilled 675 39.2
Criteria2 <- subset(CO2, conc == 250)
Criteria3 <- subset(Criteria2, Treatment == "chilled")
head (Criteria3)## Plant Type Treatment conc uptake
## 24 Qc1 Quebec chilled 250 30.3
## 31 Qc2 Quebec chilled 250 35.0
## 38 Qc3 Quebec chilled 250 38.1
## 66 Mc1 Mississippi chilled 250 18.1
## 73 Mc2 Mississippi chilled 250 12.3
## 80 Mc3 Mississippi chilled 250 17.9
#Here is my plotting gizmo, copy the whole gizmo and adjust the top bit as needed
# vvvvv adjust these parameters vvvvvv
library(plyr)
library(ggplot2)
xData <- Criteria2$Treatment
xLabel <- "Treatment"
yData <- Criteria2$uptake
yLabel <- "uptake"
myTitle <- "CO2"
fontSize <- 18 # Adjust font size
# ^^^^^ adjust these parameters ^^^^^^
# vvvvv leave everything below alone! vvvvvv
temp.df <- data.frame(xData, yData)
temp.df <- na.omit(temp.df)
meansErrBars.df <- ddply(temp.df, c("xData"), summarise, N=sum(yData), mean=mean(yData), sd=sd(yData), se=sd/sqrt(N))
graphIT <- ggplot(data = meansErrBars.df, aes(x = xData, y = mean))
limits <- aes(ymax = meansErrBars.df$mean + meansErrBars.df$se, ymin = meansErrBars.df$mean - meansErrBars.df$se)
dodge <- position_dodge(width = 1)
graph_output <- graphIT +
labs(x = xLabel, y = yLabel, title = myTitle) +
geom_bar(stat = "identity", position = dodge, fill="gray", color = "black") +
geom_errorbar(limits, width = 0.6, stat ="identity", position = dodge, size = 1) +
geom_point(data = temp.df, aes(x = xData, y = yData), position = dodge, size = 8, shape=1) +
theme_classic() + theme(axis.text=element_text(size=fontSize*3.5/4),
axis.title.y=element_text(size=fontSize,face="bold", vjust=1.5),
axis.title.x=element_text(size=fontSize,face="bold", vjust=-0.3),
plot.title = element_text(size=fontSize,face="bold", vjust=1.5),
panel.border = element_rect(colour = "black", fill=NA, size=3))
print(graph_output)Figure 1: WRITE CAPTION HERE.
remove(temp.df, meansErrBars.df, graphIT, limits, dodge, fontSize, myTitle, xData, xLabel, yData, yLabel) #clean upFigure 2: WRITE CAPTION HERE.
Please turn–in your homework via Sakai by saving and submitting an R Markdown PDF or HTML file from R Pubs!