# The MIT License # Copyright (c) 2007 The GGobi Foundation # http://www.ggobi.org/book/code-license.txt # Read data d.olive<-read.csv("olive.csv",row.names=1) d.olive.sub <- subset(d.olive, select=c(region,palmitic:eicosenoic)) # load libraries library(rpart) # Fitting the tree olive.rp <- rpart(region~., d.olive.sub, method="class") olive.rp # Create new variable linoarach<-0.969/1022*d.olive[,7]+0.245/105*d.olive[,9] # Refit model olive.rp<-rpart(region~.,data.frame(cbind(d.olive[,-c(2,7,9)],linoarach)), method="class")