rpart.plot (version 2.2.0)

rpart.plot.version1: Plot an rpart model (old version).

Description

This function is provided for backward compatibility with old versions of rpart.plot (prior to version 2.0.0, June 2016).

By default this function creates a minimal unadorned plot, whereas rpart.plot creates a colored plot automatically tailored to the model's type.

Actually, the only difference between the two functions is that some arguments have different defaults. This function has the same defaults as prp. See the rpart.plot help page for a table showing the different defaults.

Usage

rpart.plot.version1(x=stop("no 'x' arg"),
    type=0, extra=0,
    under=FALSE, fallen.leaves=FALSE,
    digits=2, varlen=-8, faclen=3,
    cex=NULL, tweak=1,
    snip=FALSE,
    box.palette=0, shadow.col=0,
    ...)

Arguments

x

Same as rpart.plot.

type

Default 0. Same as rpart.plot.

extra

Default 0, otherwise the same as rpart.plot (which has a default of "auto").

under

Default FALSE. Same as rpart.plot.

fallen.leaves

Default FALSE, otherwise the same as rpart.plot (which has a default of TRUE).

digits

Default 2. Same as rpart.plot.

varlen

Default -8, otherwise the same as rpart.plot (which has a default of 0).

faclen

Default 3, otherwise the same as rpart.plot (which has a default of 0).

cex

Default NULL. Same as rpart.plot.

tweak

Default 1. Same as rpart.plot.

snip

Default FALSE. Same as rpart.plot.

box.palette

Default 0, otherwise the same as rpart.plot (which has a default of "auto").

shadow.col

Default 0. Same as rpart.plot.

Same as rpart.plot.

Value

The returned value is identical to that of prp.

Examples

Run this code
# NOT RUN {
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.version1(tree, main="default rpart.plot.version1\n(type = 0, extra = 0)")

rpart.plot.version1(tree, main="type = 4, extra = 6",
                    type=4, extra=6, faclen=0) # faclen=0 to print full factor names

rpart.plot.version1(tree, main="extra = 106,  under = TRUE",
                    extra=106, under=TRUE, faclen=0)

# compare to the plotting functions in the rpart package
plot(tree, uniform=TRUE, compress=TRUE, branch=.2)
text(tree, use.n=TRUE, cex=.8, xpd=NA) # cex is a guess, depends on your window size
title("compare to the plotting functions\nin the rpart package", cex.sub=.8)

par(old.par)
# }

Run the code above in your browser using DataCamp Workspace