| template | R Documentation |
Takes your fitted model and prints a ready-to-run starting template (node list, path list, title list, note list, and
diyPaths() call) to the console. Copy the output into your script, then fine-tune the diagram by adjusting values in the lines marked #EDIT ME!
The template is also returned invisibly as a character string, so it can be stored as an object then viewed
with writeLines() (see examples).
template(
fit,
include_variance_paths = TRUE,
diyPaths_arguments = c("max", "min"),
quiet = FALSE
)
fit |
A fitted model object of class |
include_variance_paths |
Logical. Whether to include variance/residual paths in the path list. Default is |
diyPaths_arguments |
Use either "max" (the printed call shows every |
quiet |
Logical. If |
Invisibly returns the template as a single character string. Unless quiet = TRUE,
it is also printed to the console.
diyPaths() to render the diagram from the template;
node(), path(), panel_title(), and panel_note() for the helper functions the template uses.
library(lavaan)
data(HolzingerSwineford1939, package = "lavaan")
#specify the model
sem_model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
speed ~ visual + textual
visual ~~ textual
'
#fit the model
fit <- sem(sem_model, data = HolzingerSwineford1939)
#print the maximal template to the console
# template(fit = fit, include_variance_paths = TRUE, diyPaths_arguments = "max", quiet = FALSE)
#store the template without printing it, then view it
tmpl <- template(fit = fit, diyPaths_arguments = "min", quiet = TRUE)
writeLines(tmpl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.