TP 4: Introduction to probabilities
data(CO2)
data1 <- CO2[,-c(2,3)]
data1 <- data.frame(data1,id=1:NROW(data1))
data1 <- data1[order(data1$uptake),]
data2 <- CO2[,-c(4,5)]
data2 <- data.frame(data2,id=1:NROW(data1))
names(data2) <- c("Plant","origin","change","number")
write.table(data1,"data1.txt",sep=",")
write.table(data2,"data2.txt",sep=" ")
rm(list=ls())
data1 <- read.table("data1.txt",header=T,sep=",")
data2 <- read.table("data2.txt",header=T,sep=" ")
myCO2 <- merge(data1,data2,by.x="id",by.y="number")
myCO2 <- myCO2[,-c(1,5)]
table(z)["non","oui"]/sum(table(z)) table(z)["oui","oui"]/sum(table(z)[,"oui"]) sum(table(z)[,"oui"])/sum(table(z))
set.seed(100)
light <- sample(c("low","mid","high"),200,replace=T,prob=c(1/3,1/3,1/3))
temp <- sample(c("low","mid","high"),200,replace=T,prob=c(1/3,1/3,1/3))
pressure <- sample(c("low","mid","high"),200,replace=T,prob=c(1/3,1/3,1/3))
mydata <- data.frame(light,temp,pressure)
table(mydata)["high","high","high"]