registerSemPlotImporter: Register a third-party semPlotModel importer

View source: R/00classes.R

registerSemPlotImporterR Documentation

Register a third-party semPlotModel importer

Description

registerSemPlotImporter lets other packages (or users) plug a converter for their model class into semPlotModel without modifying semPlot: when semPlotModel (and hence semPaths) receives an object whose class matches a registered importer, that importer is called instead of the built-in dispatch.

validateSemPlotModel checks the invariants that semPaths relies on and stops with a message listing all violations; it is called automatically by semPaths and is exported so importer authors can test their converters.

Usage

registerSemPlotImporter(class, fun)
validateSemPlotModel(object)

Arguments

class

A single class name (character).

fun

A function function(object, ...) returning a valid semPlotModel-class object.

object

A "semPlotModel" object to validate.

Details

The returned model must contain a Pars data frame with the columns label, lhs, edge, rhs, est, std, group, fixed and par, and a Vars data frame with name, manifest and exogenous. Recognized edge types are "->" (factor loading), "~>" (regression), "<->" ((co)variance), "--" (undirected network edge), "int" (intercept; lhs must be "") and "|" (threshold). Registered importers take precedence over the built-in dispatch.

Value

registerSemPlotImporter returns NULL invisibly; validateSemPlotModel returns the object invisibly or stops.

Author(s)

Sacha Epskamp <mail@sachaepskamp.com>

Examples

## Not run: 
# In a package providing models of class "myModel":
registerSemPlotImporter("myModel", function(object, ...){
  # ... build and return a semPlotModel object ...
})
# Afterwards this works directly:
# semPaths(myModelObject)

## End(Not run)

semPlot documentation built on July 18, 2026, 1:06 a.m.