Last active
January 25, 2017 12:26
-
-
Save aammd/91303a618dd95e04cc46c1b046b0e7b8 to your computer and use it in GitHub Desktop.
i just want a simple tree tho
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Author
aammd
commented
Jan 25, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment