View source: R/S02-legacy_functions.R
sep | R Documentation |
Determine the distance between x-axis or y-axis coordinates for two nodes in a path diagram.
sep(nodes, labels, dimension = "y-axis", desired = NULL)
nodes |
A list of lists, each list
giving the x and y coordinates for the
bottom, left, top, right and associated
corners for a given node (e.g., see output
of |
labels |
Either...
|
dimension |
The set of coordinates to
compare between nodes, either |
desired |
An optional value specifying the desired distance between the two nodes; when provided, the function outputs the new x or y-axis coordinate needed for the second node to have the desired distance from the first node. |
# Create simple path diagram
create_base_figure()
# Add nodes
nodes <- add_nodes(
c( N1 = 'Node-01|x=.3|y=.7',
N2 = 'Node-02|x=.7|y=.3' ),
output = TRUE )
# Distance from bottom of node 'N1'
# and top of node 'N2'
sep( nodes, c( 'N1', 'N2' ) )
# Determine new y-axis coordinate for 'N2' so
# that distance between nodes would be 0.1
sep( nodes, c( 'N1', 'N2' ), desired = .1 )[2]
# Add new node using proposed y-axis coordinate
add_nodes( c( N3 = 'Node-03|x=.3|y=.534' ) )
# Determine new y-axis coordinate for 'N1' so
# that distance between nodes would be 0.1
sep( nodes, c( 'N2', 'N1' ), desired = .1 )[2]
# Add new node using proposed y-axis coordinate
add_nodes( c( N4 = 'Node-04|x=.7|y=.466' ) )
# Distance from left edge of 'N1' and
# right edge of 'N2'
sep( nodes, c( 'N1', 'N2' ), dimension = 'x-axis' )
# Determine new x-axis coordinate for 'N2' so
# that distance between nodes would be 0.1
sep( nodes, c( 'N1', 'N2' ), 'x-axis', desired = .1 )[2]
# Add new node using proposed x-axis coordinate
add_nodes( c( N5 = 'Node-05|x=.589|y=.7' ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.