Skip to content

Instantly share code, notes, and snippets.

@aammd
Last active January 25, 2017 12:26
Show Gist options
  • Save aammd/91303a618dd95e04cc46c1b046b0e7b8 to your computer and use it in GitHub Desktop.
Save aammd/91303a618dd95e04cc46c1b046b0e7b8 to your computer and use it in GitHub Desktop.
i just want a simple tree tho
library(dplyr)
library(igraph)
library(ggplot2)
library(ggraph)
ed <- frame_data(
~from, ~to,
"a", "b",
"a", "c",
"c", "e"
) %>%
as.data.frame
vt <- frame_data(
~name, ~colour,
"a", 1,
"b", 1,
"c", 2,
"e", 2
) %>%
as.data.frame
graph_from_data_frame(d = ed, vertices = vt) %>%
ggraph(layout = "igraph", algorithm = "tree") +
geom_edge_link0() +
geom_node_label(aes(label = name, fill = colour))
@aammd
Copy link
Author

aammd commented Jan 25, 2017

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment