# Small example to illustrate rpart() on the car.test.frame data library("rpart") set.seed(784) car.test.frame[sample(nrow(car.test.frame), 4), ] car.tree <- rpart(Mileage ~ Weight, car.test.frame, method = "anova") car.tree printcp(car.tree) summary(car.tree) names(car.tree) if (FALSE) { postscript("cartree.eps", horiz = FALSE, onefile = FALSE, print.it = FALSE, width = 5.0, height = 3.0) } else { pdf("cartree.pdf", onefile = FALSE, width = 5.0, height = 3.0) } # partition(car.tree) # par(mar = c(5, 4, 2, 2) + 0.8, mfrow = c(1, 1), xpd = TRUE) par(xpd = TRUE, cex = 1.0) plot(car.tree) text(car.tree) dev.off()