model <- 'alpha =~ x1 + x2 + x3 # latent variable
beta <~ x4 + x5 + x6 # composite
gamma =~ x7 + x8 + x9 # latent variable
Xi =~ x10 + x11 + x12 + x13 # latent variable
# regressions
Xi ~ v * alpha + t * beta + 1
alpha ~ yy * Theta1 + tt * beta + ss * gamma
'
test <- lav_model_plotinfo(model)
test <- lav_plotinfo_positions(test)
lav_plotinfo_svgcode(test) # no file given, so output to R console
modelml <- '
level: 1
fw =~ 1*y_1 + y_2 + y_3 + y_5
level: 2
fb =~ 1*y_1 + y_2 + y_3 + y_4
y_2 ~~ cv24 * y_4
'
testml <- lav_model_plotinfo(modelml)
testml <- lav_plotinfo_positions(testml)
# in the line hereunder no file is given, so output to R console
lav_plotinfo_svgcode(testml, sloped_labels = FALSE, standalone = TRUE,
auto_subscript = FALSE)
if (FALSE) {
# example creating html file with the above diagrams
zz <- file("demosvg.html", open="w")
writeLines(c(
'',
'',
'',
'SVG diagrams created by lav_plot R package'),
zz)
lav_plotinfo_svgcode(test, outfile = "temp.svg")
tmp <- readLines("tmp.svg")
writeLines(tmp, zz)
writeLines("", zz)
lav_plotinfo_svgcode(testml, outfile = "temp.svg", sloped_labels = FALSE,
standalone = TRUE)
tmp <- readLines("tmp.svg")
writeLines(tmp, zz)
writeLines(c("", ""), zz)
close(zz)
browseURL("demosvg.html")
}
Run the code above in your browser using DataLab