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

sample tree

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

enter image description here


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -