Reputation: 1235
Let's say I have an existing numeric vector num <- c(1, 2, 3, 4, 5, 6, 7)
and I need to visualize it in the simplest way possible (every node have two children) -- like this (sorry, I'm definitely not an artist):
Is it possible with R?
Upvotes: 0
Views: 102
Reputation: 54237
Try this:
num <- c(1, 2, 3, 4, 5, 6, 7)
library(igraph)
library(psych)
g <- graph.edgelist(matrix(c(rep(seq_len((length(num)-1) / 2), each = 2), num[-1]), ncol = 2))
plot(g, layout = factor.rotate(layout.reingold.tilford(g), angle = -90), ylim = c(1, -1))
Upvotes: 2