keep_drop_nodes {semptools} | R Documentation |
Keep or drop nodes
Description
Keep or drop nodes from an semPlotModel object.
Usage
drop_nodes(object, nodes)
keep_nodes(object, nodes)
Arguments
object |
An an |
nodes |
A character vector of the nodes to be kept or removed. |
Details
These functions can be used to edit the nodes in an
semPlot::semPlotModel
generated by semPlot::semPlotModel()
.
The edited object can then be passed to semPlot::semPaths()
to
generate a path diagram.
Use keep_nodes()
to specify the nodes to be kept. All other nodes
will be removed.
Use drop_nodes()
to specify the nodes to be dropped. All other
nodes will be kept.
Value
An object of the class semPlot::semPlotModel
.
Examples
mod_pa <-
'x1 ~~ x2
x3 ~ x1 + x2
x4 ~ x1 + x3
'
fit_pa <- lavaan::sem(mod_pa, pa_example)
m <- matrix(c("x1", NA, NA,
NA, "x3", "x4",
"x2", NA, NA), byrow = TRUE, 3, 3)
pm_pa <- semPlot::semPlotModel(fit_pa)
semPlot::semPaths(pm_pa, whatLabels = "est",
style = "ram",
nCharNodes = 0, nCharEdges = 0,
layout = m)
pm_pa2 <- drop_nodes(pm_pa, c("x3"))
semPlot::semPaths(pm_pa2, whatLabels = "est",
style = "ram",
nCharNodes = 0, nCharEdges = 0,
layout = m)
pm_pa3 <- keep_nodes(pm_pa, c("x1", "x3", "x4"))
semPlot::semPaths(pm_pa3, whatLabels = "est",
style = "ram",
nCharNodes = 0, nCharEdges = 0,
layout = m)
[Package semptools version 0.2.10 Index]