| open_parser | R Documentation |
The lavaan model syntax parser can be extended with new operators, modifiers and groupings. These extensions are only used in the 'open' parser.
lav_parse_options(
pkgname = NULL,
operators = NULL,
modifiers = NULL,
groupings = NULL
)
pkgname |
The name of the package that extends the elements. |
operators |
A character vector with new operators. These operators must start and end with a percentage sign and be at least 3 characters long. |
modifiers |
A data.frame with columns |
groupings |
A character vector with new groupings; they must be in snake_case. |
A list with data.frames containing the currently active parser configuration.
curconfig <- lav_parse_options("testPKG",
operators = c('%w%', '%q%'),
modifiers = data.frame(mod = c("linksc", "linksn", "rechtsn"),
side = c("l", "l", "r"),
expect = c("char", "num", "raw")),
groupings = c("color", "colour")
)
for (j in seq_along(curconfig)) {
cat(names(curconfig)[j], ":\n")
print(curconfig[[j]])
}
model <- '
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + a*y2 + start(0.3)*b*y3 + upper(0.99)*c*y4
dem65 =~ y5 + a*y6 + b*y7 + rechtsn(2 * pi / 3)*c*y8
dem60 %w% aa *0.2*y4
dem60 ~ ind60
dem65 ~ ind60 + dem60
linksc("klopt") * dem60 =~ aaa * y8
linksn(sqrt(23.5)) * dem60 =~ bbb * y9
efa("efatje") * dem65 =~ xyz * x3
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
print(result <- lavParseModelString(model, TRUE, parser = "open"))
print(attributes(result))
model2 <- '
color: green
level: 1
fw =~ y1 + y2 + y3
fw ~ x1 + x2 + x3
level: 2
fb =~ y1 + y2 + y3
fb ~ w1 + w2
color: blue
level: 1
fw =~ y1 + y2 + y3
fw ~ x1 + x2 + x3
level: 2
fb =~ y1 + y2 + y3
fb ~ w1 + w2
'
print(result2 <- lavParseModelString(model2, TRUE, parser = "open"))
print(attributes(result2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.