rpart.plot (version 3.1.2)

rpart.rules: Print an rpart model as a set of rules.

Description

Print an rpart model as a set of rules.

Usage

rpart.rules(x = stop("no 'x' argument"),
            style = "wide", cover = FALSE, nn = FALSE,
            roundint = TRUE, clip.facs = FALSE,
            varorder = NULL, ...)

# S3 method for rpart.rules print(x = stop("no 'x' argument"), style = attr(x, "style"), ...)

Value

A data.frame of class c("rpart.rules", "data.frame")

with some attached attributes which are passed on to print.rpart.rules. Note that print.rpart.rules temporarily increases options(width).

Arguments

x

An rpart object. The only required argument.

style

One of:
"wide" (default) One rule per line. May require a lot of horizontal space.
"tall" One split per line.
"tallw" Like "tall" but with more horizontal white space for readability.

cover

Default FALSE. If TRUE, also print the percentage of cases covered by each rule.

nn

Default FALSE. If TRUE, also print the leaf node number for each rule.

roundint

If roundint=TRUE (default) and all values of a predictor in the training data are integers, then splits for that predictor are rounded to integer. For example, display nsiblings < 3 instead of nsiblings < 2.5.
Identical to the argument of the same name in rpart.plot, see there for details.

clip.facs

Default FALSE. If TRUE, print splits on factors as female instead of sex = female; the variable name and equals is dropped.
Identical to the argument of the same name in rpart.plot.

varorder

By default, the variables in the rules are ordered left to right on importance, where the ``importance'' of a variable here is the number of rules it appears in.
Use varorder to force variables to appear first in the rules. For example varorder="sex" or varorder=c("sex", "pclass") will put the specified variables first.
Partial matching of variable names is supported.

...

The following can be passed as dot arguments. See prp for details on these arguments.

argumentdefault
extra= "auto"a subset of the legal values for prp are supported
digits= 2default is two digits of accuracy, increase if necessary
varlen= 0default displays full variable names
faclen= 0default displays full factor names
trace= 0
facsep= " or "
eq= " is "
lt= " < "
ge= " >= "
and= " & "
when= " when "
because= " because "used only by rpart.predict
null.model= "null model"for root-only models (no splits)
response.name= NULLthe response name printed before the rules (NULL means automatic)

See Also

rpart.plot

Examples

Run this code
data(ptitanic)
model <- rpart(survived ~ ., data = ptitanic, cp = .02)
rpart.plot(model)
rpart.rules(model)

Run the code above in your browser using DataCamp Workspace