attach(Pollute)
names(Pollute)

model<-tree(Pollute)
plot(model,type="u")
text(model)

attach(Pollute)
names(Pollute)

model<-tree(Pollution ~ . , Pollute)

plot(model)
text(model)

print(model)

attach(car.test.frame)
names(car.test.frame)

plot(Weight,Mileage)

a<-mean(Mileage[Weight<2567.5])
b<-mean(Mileage[Weight>=2567.5])
lines(c(1500,2567.5,2567.5,4000),c(a,a,b,b))

car.model<-tree(Mileage~Weight)
plot(Weight,Mileage)
wt<-seq(1500,4000,10)
y<-predict(car.model,list(Weight=wt))
lines(wt,y)

prune.tree(model)

plot(prune.tree(model))

model2<-prune.tree(model,best=4)
plot(model2,type="u")
text(model2)

model2

attach(epilobium)
epilobium

model<-tree(species~.,epilobium,mindev=1e-6,minsize=2)
plot(model)
text(model)  

attach(taxonomy)
names(taxonomy)

model1<-tree(Taxon~.,taxonomy)

plot(model1)
text(model1)

summary(model1)

print(model1)

model2<-tree(Taxon~Sepal+Leaf,taxonomy)
partition.tree(model2)

label<-ifelse(Taxon=="I", "a", ifelse(Taxon=="II","b",ifelse(Taxon=="III","c","d")))

text(Sepal,Leaf,label)

