View source: R/lavaan_helpers.R
lav_to_graph | R Documentation |
Converts lavaan syntax or object to graphviz code. Requires 'DiagrammeR' package.
lav_to_graph(
m,
layout = "dot",
adds = NULL,
file = NA,
rmarkdown = FALSE,
code.only = F,
try.labels = T,
label.wrap = 15,
std = F,
elements = c("obs", "lat.covs", "resid.covs", "resid", "slopes"),
...
)
m |
character, following lavaan syntax model conventions (see examples), or fitted lavaan object. |
layout |
Can be 'dot', 'neato', 'twopi', 'circo', or 'fdp' |
adds |
Any graphviz code to be added to the graph. |
file |
character, file name to save svg code, usually with 'svg' extension. |
rmarkdown |
Logical. If the function used in the context of Rmarkdown. |
try.labels |
Try extracting labels from the data. |
label.wrap |
Number of character to wrap a label |
std |
Whether include standardized or unstandardized estimates. |
elements |
Character vector. What to include in the diagram, possible values "obs", "lat.covs", "resid.covs", "resid", "slopes", and "intercepts/thresholds" (currently not supported). |
... |
arguments passed to DiagrammeR::grViz function. |
The function invisibly returns the dot code which can be edited to make more customized diagrams. You can use package DiagrammeR or any other graphviz engine, e.g. http://graphviz.it. It will most likely to be useful with large and complex models.
lav_to_graph("F =~ a1 + a2 + a3 + a4")
lav_to_graph("F =~ a1 + a2 + a3 + a4; a1 ~~ a2; d ~ F ", engine = "neato")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.