TP 3: Graphics and data.frames
pairs(CO2[,-1])
write.table(CO2,file="mydata.txt",sep=",")
mydata <- read.table("mydata.txt",sep=",",header=T)
sum(CO2$Type=="Quebec" & CO2$uptake>35 & CO2$Treatment=="chilled")
index <- which(CO2$conc==min(CO2$conc)) which(CO2$uptake==max(CO2$uptake[index]))
maxuptake <- function(nameplant){
max(CO2$uptake[CO2$Plant==nameplant])
}
maxvec <- sapply(levels(CO2$Plant),maxuptake)
minuptake <- function(nameplant){
min(CO2$uptake[CO2$Plant==nameplant])
}
minmaxmat <- rbind(sapply(levels(CO2$Plant),minuptake),maxvec)
barplot(minmaxmat,beside=T,col=c("red","blue"),main="minima and maxima of uptakes by plant")
uptakemat <- matrix(CO2$uptake,nr=7) rownames(uptakemat) <- CO2$conc[1:7] colnames(uptakemat) <- unique(CO2$Plant) heatmap(uptakemat,Rowv=NA,Colv=NA)
par(mfrow=c(1,2))
plot(CO2$conc,CO2$uptake)
barplot(minmaxmat,col=c("red","blue"),main="minima and maxima of uptakes by plant")