Q: In DiagrammeR
native syntax, how does one force certain nodes to be on the same rank?
E.g., below I was able to force nodes 4, 5, 6, 7 onto the same rank by creating an invisible node 2, with invisible edges in and out of it. But this is just a hack. And the resulting diagram is a little off balance. There must be a better way to do this, right?
library(DiagrammeR)
g <- create_graph(attr_theme="tb")
g <- add_node(g) # node 1
g <- add_node(g, from=1, node_aes = node_aes(style = "invisible"), edge_aes = edge_aes(style = "invisible", arrowhead = "none")) # node 2, my invisible node
g <- add_node(g, from=1, edge_aes = edge_aes(style = "solid")) # node 3
g <- add_node(g, from=2, edge_aes = edge_aes(style = "invisible", arrowhead = "none")) # node 4
g <- add_node(g, from=2, edge_aes = edge_aes(style = "invisible", arrowhead = "none")) # node 5
g <- add_edge(g, from=1,to=4, edge_aes = edge_aes(style = "solid"))
g <- add_edge(g, from=1,to=5, edge_aes = edge_aes(style = "solid"))
g <- add_node(g, from=3) # node 6
g <- add_node(g, from=3) # node 7
render_graph(g)