pupae<- read.csv("pupae.csv")
pupae$CO2_treatment <- as.factor(pupae$CO2_treatment)
levels(pupae$CO2_treatment)
## [1] "280" "400"
par(cex.lab=1.3)
with(pupae, plot(Frass, PupalWeight, pch=19, cex=0.5, col=CO2_treatment))
legend("topleft", levels(pupae$CO2_treatment), fill=palette(), title="Frass versus Pupal weight by CO2treatment")

pupaeambient <- subset(pupae, T_treatment=="ambient")
pupaeelevated <- subset(pupae, T_treatment=="elevated")
# Set up two figures next to each other:
par(mfrow=c(1,2))
# Simple scateerplots, default settings.
par(cex.lab=1.3)
with(pupaeambient, plot(Frass, PupalWeight, pch=19, cex=0.5, col=CO2_treatment))
legend("topleft", levels(pupae$CO2_treatment), fill=palette(), title="Frass versus Pupal weight by CO2treatment")
par(cex.lab=1.3)
with(pupaeelevated, plot(Frass, PupalWeight, pch=19, cex=0.5, col=CO2_treatment))
legend("topleft", levels(pupae$CO2_treatment), fill=palette(), title="Frass versus Pupal weight by CO2treatment")

# Read the data. Avoid conversion to factors.
flux <- read.csv("Fluxtower.csv", stringsAsFactors=FALSE)
# Convert to a proper DateTime class:
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
flux$TIMESTAMP <- dmy_hm(flux$TIMESTAMP)
# Add the Date :
flux$Date <- as.Date(flux$TIMESTAMP)
# Select one day.
fluxsubs <- subset(flux, Date==as.Date("2009-02-24"))
with(fluxsubs, plot(FCO2, type='l'))

# Read data.
allom <- read.csv("Allometry.csv")
# Make a factor variable with 10 levels of branch mass.
allom$branchmassbin <- cut(allom$branchmass, breaks=10)
# Look at the levels
levels(allom$branchmassbin)
## [1] "(0.597,120]" "(120,238]" "(238,356]"
## [4] "(356,474]" "(474,592]" "(592,710]"
## [7] "(710,828]" "(828,946]" "(946,1.06e+03]"
## [10] "(1.06e+03,1.18e+03]"
# Set colours correspondingly, from red to green.
redgreenfun <- colorRampPalette(c("red","green"))
palette(redgreenfun(10))
# Plot leafarea and height, with the colour of the symbol varying by branchmassbin .
par(cex.lab=1.3)
with(allom, plot(height, leafarea, pch=19, cex=0.5, col=branchmassbin))
#Add a legend:
legend("topleft", levels(allom$branchmassbin), fill=palette(), title="branch mass")
