geom_edge: Draw edges

Description Usage Arguments See Also Examples

View source: R/ggparty.R

Description

Draws edges between children and parent nodes. Wrapper for ggplot2::geom_segment()

Usage

1
2
geom_edge(mapping = NULL, nudge_x = 0, nudge_y = 0, ids = NULL,
  show.legend = NA, ...)

Arguments

mapping

Mapping of x, y, xend and yend defaults to ids' and their parent's coordinates. Other mappings can be added here as aes().

nudge_x, nudge_y

Nudge labels.

ids

Choose which edges to draw by their children's ids.

show.legend

logical See layer().

...

Additional arguments for geom_segment().

See Also

ggparty(), geom_edge()

Examples

 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")

Example output

Loading required package: ggplot2
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm

ggparty documentation built on July 18, 2019, 5:04 p.m.