View source: R/set_edge_label_position.R
set_edge_label_position | R Documentation |
Set the positions of edge labels of selected edges.
set_edge_label_position(semPaths_plot, position_list = NULL)
semPaths_plot |
A qgraph::qgraph object generated by semPlot::semPaths, or a similar qgraph object modified by other semptools functions. |
position_list |
A named vector or a list of named lists. For a
named vector, the name of an element should be the path as
specified by lavaan::model.syntax or as appeared in
|
Modify a qgraph::qgraph object generated by semPlot::semPaths and change the edge label positions of selected edges.
A qgraph::qgraph based on the original one, with edge label positions for selected edges changed.
mod_pa <-
'x1 ~~ x2
x3 ~ x1 + x2
x4 ~ x1 + x3
'
fit_pa <- lavaan::sem(mod_pa, pa_example)
lavaan::parameterEstimates(fit_pa)[, c("lhs", "op", "rhs", "est", "pvalue")]
m <- matrix(c("x1", NA, NA,
NA, "x3", "x4",
"x2", NA, NA), byrow = TRUE, 3, 3)
p_pa <- semPlot::semPaths(fit_pa, whatLabels="est",
style = "ram",
nCharNodes = 0, nCharEdges = 0,
layout = m)
my_position_vector <- c("x3 ~ x2" = .25,
"x4 ~ x1" = .75)
p_pa2v <- set_edge_label_position(p_pa, my_position_vector)
plot(p_pa2v)
my_position_list <- list(list(from = "x2", to = "x3", new_position = .25),
list(from = "x1", to = "x4", new_position = .75))
p_pa2l <- set_edge_label_position(p_pa, my_position_list)
plot(p_pa2l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.