parseMplus: Check Mplus code for missing semicolons or too long lines.

View source: R/mplus.R

parseMplusR Documentation

Check Mplus code for missing semicolons or too long lines.

Description

The function parses a character string containing Mplus code and checks that every non blank line ends in either a colon or a semicolon. In addition, it checks that every line is less than 90 characters, because Mplus ignores everything after 90 characters on a line which can be a source of enigmatic errors.

Usage

parseMplus(x, add = FALSE)

Arguments

x

a character string containing Mplus code.

add

logical indicating whether or not to add semicolons to lines that do not have them. Defaults to FALSE.

Details

The function is fairly basic at the moment. It works by simply removing blank space (spaces, tabs, etc.) and then if a line does not terminate in a colon or semicolon, it returns a note and the line number. Optionally, it can add semicolons to any lines missing them and return the input with added semicolons. To check for lines that are too long, all trailing (but not before) white space is removed, and then the number of characters is checked.

Value

a character vector containing the input text and optionally added semicolons.

Author(s)

Joshua F. Wiley <jwiley.psych@gmail.com>

See Also

mplusModeler

Examples


# sample input
test <- "
MODEL:
  mpg ON wt hp;
  wt WITH hp
"
# check and return
cat(parseMplus(test), file=stdout(), fill=TRUE)
# add missing semicolons and return
cat(parseMplus(test, TRUE), file=stdout(), fill=TRUE)
# line that is too long for Mplus
test <- "
MODEL:
  mpg cyl disp hp drat wt qsec vs am gear PWITH cyl disp hp drat wt qsec vs am gear carb;
"
cat(parseMplus(test), file=stdout())

MplusAutomation documentation built on April 7, 2022, 1:06 a.m.