Description Usage Arguments Details See Also Examples
ggplot2
extension for objects of class party
. Creates a data.frame
from
an object of class party
and calls ggplot()
1 2 |
party |
Object of class |
horizontal |
If |
terminal_space |
Proportion of the plot that should be reserved for
the terminal nodeplots. Defaults to |
layout |
Optional layout adjustment. Overwrites the coordinates of the
specified nodes. Must be |
add_vars |
Named list containing either string(s) specifying the locations
of elements to be extracted from
each node of |
ggparty
can be called directly with an object of class party
, which will
convert it to a suitable data.frame
and pass it to a call to ggplot
with as
the data
argument. As usual, additional components can then be added with
+
.
The nodes will be spaced equally in the unit square. Specifying
terminal_size
allows to increase or decrease the area for plots of the
terminal nodes.
If one of the list entries supplied to add_vars
is a function, it has to take
exactly two arguments,
namely data
(the corresponding row of the plot_data data frame) and node
(the corresponding node, i.e. party_object[i]
)
geom_edge()
, geom_edge_label()
, geom_node_label()
,
autoplot.party()
, geom_node_plot()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(ggparty)
data("WeatherPlay", package = "partykit")
sp_o <- partysplit(1L, index = 1:3)
sp_h <- partysplit(3L, breaks = 75)
sp_w <- partysplit(4L, index = 1:2)
pn <- partynode(1L, split = sp_o, kids = list(
partynode(2L, split = sp_h, kids = list(
partynode(3L, info = "yes"),
partynode(4L, info = "no"))),
partynode(5L, info = "yes"),
partynode(6L, split = sp_w, kids = list(
partynode(7L, info = "yes"),
partynode(8L, info = "no")))))
py <- party(pn, WeatherPlay)
ggparty(py) +
geom_edge() +
geom_edge_label() +
geom_node_label(aes(label = splitvar),
ids = "inner") +
geom_node_label(aes(label = info),
ids = "terminal")
|
Loading required package: ggplot2
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.