Title: Graphical User Interface with Integrated 'Diagrammer' for 'Lavaan'
Version: 0.4.0
Description: Provides a graphical user interface with an integrated diagrammer for latent variable models from the 'lavaan' package. It offers two core functions: first, lavaangui() launches a web application that allows users to specify models by drawing path diagrams, fitting them, assessing model fit, and more; second, plot_lavaan() creates interactive path diagrams from models specified in 'lavaan'. After customizing a diagram interactively, export_plot() saves it to a file, enabling reproducible scripts without sacrificing fine-grained control over appearance. Karch (2024) <doi:10.1080/10705511.2024.2420678> contains a tutorial.
URL: https://lavaangui.org/, https://github.com/karchjd/lavaangui
BugReports: https://github.com/karchjd/lavaangui/issues
License: GPL (≥ 3)
Imports: base64enc (≥ 0.1.3), future (≥ 1.33.0), haven (≥ 2.5.3), jsonlite (≥ 1.8.4), lavaan (≥ 0.6-20), promises (≥ 1.2.0.1), readr (≥ 2.1.4), readxl (≥ 1.4.3), shiny (≥ 1.7.4), methods (≥ 4.3.3), colorspace (≥ 2.1.0), igraph (≥ 2.0.3), tools (≥ 4.3.3), utils (≥ 4.3.3), DT (≥ 0.33), plyr (≥ 1.8.9), digest (≥ 0.6.35)
Encoding: UTF-8
RoxygenNote: 7.3.3
Language: en-US
NeedsCompilation: no
Packaged: 2026-04-14 09:47:47 UTC; karch
Author: Julian D. Karch ORCID iD [aut, cre, cph]
Maintainer: Julian D. Karch <j.d.karch@fsw.leidenuniv.nl>
Repository: CRAN
Date/Publication: 2026-04-14 10:10:02 UTC

lavaangui: Graphical User Interface with Integrated 'Diagrammer' for 'Lavaan'

Description

The lavaangui package provides a free, open-source graphical user interface for the lavaan package. Models can be specified by drawing path diagrams and fitted models can be visualized via interactive path diagrams.

The package offers two core functions:

lavaangui

Launches a web application that allows users to specify models by drawing path diagrams, fit them, and assess model fit.

plot_lavaan

Creates interactive path diagrams from fitted lavaan models. Nodes can be repositioned by dragging them with the mouse.

The web application can also be used without installing R at https://lavaangui.org/.

Author(s)

Maintainer: Julian D. Karch j.d.karch@fsw.leidenuniv.nl (ORCID) [copyright holder]

References

Karch, J. D. (2025). lavaangui: A Web-Based Graphical Interface for Specifying Lavaan Models by Drawing Path Diagrams. Structural Equation Modeling: A Multidisciplinary Journal, 1–12. doi:10.1080/10705511.2024.2420678

See Also

Useful links:


Export a Path Diagram of a Lavaan Model to a File

Description

Renders the path diagram for a lavaan model and saves it directly to a file without requiring manual interaction.

Usage

export_plot(fit, filename, layout = "default", scale = 1)

Arguments

fit

A lavaan model, as returned by the lavaan, sem, or cfa functions from the lavaan package.

filename

A single character string giving the output file path. The file extension determines the format: png, jpg/jpeg, svg, or pdf.

layout

A character string specifying the name of a previously saved layout to use (default: "default").

scale

A positive number controlling the output resolution relative to screen size (default: 1). Higher values produce sharper raster images (PNG/JPG) and larger SVG/PDF output.

Value

nothing

See Also

plot_lavaan() to create and interactively edit path diagrams, remove_layouts() to delete saved layouts.

Examples


library(lavaan)
model <- "
  visual  =~ x1 + loadingx2*x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
fit <- cfa(model, data = HolzingerSwineford1939)
# First run plot_lavaan to interactively arrange the diagram and save a layout,
# then export it non-interactively:
plot_lavaan(fit)
export_plot(fit, "diagram.png")
export_plot(fit, "diagram.pdf", scale = 2)


Start lavaangui Shiny Application

Description

The lavaangui function launches the lavaangui Shiny application.

Usage

lavaangui(fit = NULL)

Arguments

fit

A lavaan model, as returned by the lavaan, sem, or cfa functions from the lavaan package. If provided, lavaangui imports the model and data. If left empty, lavaangui starts without importing.

Details

Currently, multiple-group models are not supported. However, you can create an interactive plot of those models using plot_lavaan

Value

nothing

Examples


# Without importing lavaan model
lavaangui()

# Importing a lavaan model
library(lavaan)
model <- "
  visual  =~ x1 + loadingx2*x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
fit <- cfa(model, data = HolzingerSwineford1939)
lavaangui(fit)


Create Interactive Path Diagrams for Lavaan Models

Description

The plot_lavaan function creates path diagrams for lavaan model. The created paths diagrams are interactive. That is, their appearance can be customized easily, for example, by dragging around nodes representing variable with the mouse.

Usage

plot_lavaan(fit, layout = "default", where = "gadget")

Arguments

fit

A lavaan model, as returned by the lavaan, sem, or cfa functions from the lavaan package.

layout

A character string specifying the name of the layout to use (default: "default"). If NULL, no layout is saved or loaded.

where

A character string to specify where the path diagram should be shown. The default value "gadget" shows it directly in Rstudio. For "browser", it's shown in your default browser. For non-RStudio users, the parameter has no effect, and the path diagram is always shown in the browser.

Details

When layout is not NULL, closing the interactive diagram saves the current graph state — including node positions and display settings (e.g., which estimates or confidence intervals are shown) — as a layout file in the working directory. This layout is automatically restored the next time you call plot_lavaan with the same model, so that you do not have to rearrange the diagram each time. Saved layouts are also used by export_plot() to export the diagram to a file non-interactively, making it easy to reproduce publication-ready figures from R scripts.

Value

nothing

See Also

export_plot() to export diagrams to a file without interaction, remove_layouts() to delete saved layouts.

Examples


library(lavaan)
model <- "
  visual  =~ x1 + loadingx2*x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
fit <- cfa(model, data = HolzingerSwineford1939)
plot_lavaan(fit)

# After arranging the diagram interactively, export it to a file:
export_plot(fit, "my_diagram.png")


Remove Saved Layouts for a Lavaan Model

Description

Removes layout files previously saved by plot_lavaan() for a given lavaan model.

Usage

remove_layouts(fit, layout = NULL)

Arguments

fit

A lavaan model, as returned by the lavaan, sem, or cfa functions from the lavaan package.

layout

A character string specifying which layout to remove. If NULL (the default), all saved layouts for the model are removed. If a character string, only the layout with that name is removed.

Value

Invisibly returns the paths of removed files.

See Also

plot_lavaan() to create and interactively edit path diagrams, export_plot() to export diagrams to a file without interaction.

Examples


library(lavaan)
model <- "
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
fit <- cfa(model, data = HolzingerSwineford1939)
remove_layouts(fit)