*R code for homework problems;
Copy and paste code one problem part at a time.
The easiest way to get slpack.txt and sldata.txt is to copy and paste the following
two commands into R.
source("http://parker.ad.siu.edu/Olive/dspack.txt")
source("http://parker.ad.siu.edu/Olive/dsdata.txt")
#If slpack.txt and sldata.txt are on J drive, get lregpack and lregdata with
#the following commands:
#source("J:/dspack.txt")
#source("J:/dsdata.txt")
## Problem 10.1, HW 10 Problem C) Regression Tree
library(rpart)
cars <- car90[, -match(c("Rim", "Tires", "Model2"), names(car90))]
carfit <- rpart(Price/1000 ~ ., data=cars)
plot(carfit)
text(carfit)
##Problem 10.2 HW 10 Problem D) Classification Tree
library(rpart)
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
plot(fit)
text(fit)