Learn R Programming

ggsem (version 0.9.9)

metadata_to_ggplot: Convert ggsem workflow metadata directly to a ggplot object

Description

This function is a convenient wrapper that takes ggsem workflow metadata, extracts the visualization data silently, and converts it to a ggplot object in one step.

Usage

metadata_to_ggplot(
  metadata,
  element_order = c("lines", "points", "loops", "annotations"),
  zoom_level = 1,
  horizontal_position = 0,
  vertical_position = 0,
  n = 100
)

Value

A ggplot object with an axis_ranges attribute specifying the x and y axis ranges after adjustments.

Arguments

metadata

A list containing ggsem workflow metadata, typically loaded from an RDS file saved by the ggsem Shiny app using the "Export Workflow" functionality or the files directory.

element_order

A character vector specifying the order in which graphical elements are added to the plot. For example: c("annotations", "loops", "lines", "points"). Elements at the front appear on top. Default includes all elements.

zoom_level

A numeric value controlling the zoom level of the plot. A value >1 zooms in; <1 zooms out. Default is 1.

horizontal_position

A numeric value to shift the plot horizontally. Default is 0.

vertical_position

A numeric value to shift the plot vertically. Default is 0.

n

Number of points used for interpolation in gradient or curved lines. Default is 100.

Details

This function combines the functionality of ggsem_silent and csv_to_ggplot into a single convenient call. It's useful when you want to go directly from saved workflow metadata to a ggplot object without intermediate steps.

Examples

Run this code
if (FALSE) {
# Load a saved ggsem workflow
workflow_metadata <- readRDS("ggsem_workflow_metadata.rds")

# Convert directly to ggplot
p <- metadata_to_ggplot(
  metadata = workflow_metadata
)

# Customize the plot further
p + ggtitle("My SEM Visualization")
}

Run the code above in your browser using DataLab