Plotting a tree in R given existing values -
let's have existing numeric vector num <- c(1, 2, 3, 4, 5, 6, 7)
, need visualize in simplest way possible (every node have 2 children) -- (sorry, i'm not artist):
is possible r?
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))
Comments
Post a Comment