View source: R/plot-plot_sem.R
| get_nodes | R Documentation |
Attempts to extract nodes from a SEM model object, where nodes are defined as observed or latent variables.
get_nodes(x, label = paste2(name, est_sig, sep = "\n"), ...)
x |
A model object of class |
label |
Either a character, indicating which column to use for node
labels, or an expression. See Details.
Defaults to |
... |
Additional parameters passed to |
The function get_nodes identifies all dependent and
independent variables in the model as nodes. If a mean structure / intercepts
are included in the model, the output of table_results for those
means / intercepts is used to label the nodes.
One way to create custom node labels is by passing an expression to
label, as in the default value of the argument. When an expression is
passed to label, it is evaluated in the context of a data.frame
containing the results
of a call to table_results on the x argument, with an
additional column labeled name, which contains the node names.
Another way to create custom labels is by requesting auxiliary variables
using the columns argument (which is passed to
table_results), and then using these columns to construct a new
label. See examples.
An object of class 'tidy_nodes'
# Standard use extracts node names and shape
# (rect for observed, oval for latent)
library(lavaan)
res <- sem("dist ~ speed", cars)
get_nodes(res)
# To label nodes with mean values, include meanstructure in the model
# Note that it is possible to pass the argument 'digits' to table_results
# through '...'
res <- sem("dist ~ speed", cars, meanstructure = TRUE)
get_nodes(res, digits = 3)
# Pass an expression to the 'label' argument for custom labels
get_nodes(res, label = paste0(name, " ", est_sig, "\n", confint))
# Pass the argument 'columns' to table_results through '...' to retain
# auxiliary columns for further processing
nod <- get_nodes(res, columns = c("est_sig", "confint"))
nod
nod <- within(nod, {label <- paste0(name, " ", est_sig, "\n", confint)})
nod
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.