data(ptitanic)
tree <- rpart(survived ~ ., data=ptitanic, cp=.02)
# cp=.02 because want small tree for demo
old.par <- par(mfrow=c(2,2))
# put 4 figures on one page
rpart.plot(tree, main="default rpart.plot
(type = 0, extra = 0)")
prp(tree, main="type = 4, extra = 6", type=4, extra=6, faclen=0)
# faclen=0 to print full factor names
rpart.plot(tree, main="extra = 106, under = TRUE", extra=106, under=TRUE, faclen=0)
# the old way for comparison
plot(tree, uniform=TRUE, compress=TRUE, branch=.2)
text(tree, use.n=TRUE, cex=.6, xpd=NA) # cex is a guess, depends on your window size
title("rpart.plot for comparison", cex=.6)
par(old.par)
Run the code above in your browser using DataLab