plot.rpart
Plot an Rpart Object
Description
Plots an rpart object on the current graphics device.
Usage
## S3 method for class 'rpart' plot(x, uniform = FALSE, branch = 1, compress = FALSE, nspace, margin = 0, minbranch = 0.3, ...)
Arguments
x | a fitted object of class |
uniform | if |
branch | controls the shape of the branches from parent to child node. Any number from 0 to 1 is allowed. A value of 1 gives square shouldered branches, a value of 0 give V shaped branches, with other values being intermediate. |
compress | if |
nspace | the amount of extra space between a node with children and a leaf, as compared to the minimal space between leaves. Applies to compressed trees only. The default is the value of |
margin | an extra fraction of white space to leave around the borders of the tree. (Long labels sometimes get cut off by the default computation). |
minbranch | set the minimum length for a branch to |
... | arguments to be passed to or from other methods. |
Details
This function is a method for the generic function plot
, for objects of class rpart
. The y-coordinate of the top node of the tree will always be 1.
Value
The coordinates of the nodes are returned as a list, with components x
and y
.
Side Effects
An unlabeled plot is produced on the current graphics device: one being opened if needed.
In order to build up a plot in the usual S style, e.g., a separate text
command for adding labels, some extra information about the plot needs be retained. This is kept in an environment in the package.
See Also
Examples
fit <- rpart(Price ~ Mileage + Type + Country, cu.summary) par(xpd = TRUE) plot(fit, compress = TRUE) text(fit, use.n = TRUE)
Copyright (©) 1999–2012 R Foundation for Statistical Computing.
Licensed under the GNU General Public License.