Learn R Programming

semPlot (version 1.2.0)

registerSemPlotImporter: 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)

Value

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

Arguments

class

A single class name (character).

fun

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

object

A "semPlotModel" object to validate.

Author

Sacha Epskamp <mail@sachaepskamp.com>

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.

Examples

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

Run the code above in your browser using DataLab