add_object: Add a Fit Object to a 'qgraph' Object

View source: R/add_object.R

add_objectR Documentation

Add a Fit Object to a 'qgraph' Object

Description

Add a fit object (e.g., 'lavaan' output) to the a 'qgraph' object as an attribute.

Usage

add_object(semPaths_plot, object)

Arguments

semPaths_plot

A qgraph::qgraph object generated by semPlot::semPaths(), or a similar qgraph::qgraph object modified by other semptools functions.

object

Should be the object, such as the output of lavaan::sem() or lavaan::cfa(), used by semPlot::semPaths() to generate semPaths_plot. Note that this function will not check whether the object is appropriate because there is no way to do so reliably.

Details

It adds an object to a qgraph::qgraph object as the attribute "semptools_fit_object", to be retrieved by other functions that need to access the original output used in semPlot::semPaths() to create a diagram.

Value

The original qgraph::qgraph object set to semPaths_plot, with the attribute "semptools_fit_object" set to object.

See Also

semPlot::semPaths()

Examples


library(lavaan)
library(semPlot)

mod <-
  'f1 =~ x01 + x02 + x03 + x06
   f2 =~ x04 + x05 + x06 + x07
   f3 =~ x08 + x09 + x10 + x03
   f4 =~ x11 + x12 + x13 + x14
  '
fit <- lavaan::cfa(mod, cfa_example)
p <- semPaths(fit,
              whatLabels = "est",
              sizeMan = 3.25,
              node.width = 1,
              edge.label.cex = .75,
              mar = c(10, 5, 10, 5),
              DoNotPlot = TRUE)
p <- add_object(p, fit)
attr(p, "semptools_fit_object")


semptools documentation built on Oct. 15, 2023, 5:07 p.m.