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.
parseMplus(x, add = FALSE)
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 |
a character vector containing the input text and optionally added semicolons.
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.
Joshua F. Wiley <jwiley.psych@gmail.com>
# sample input test <- " MODEL: mpg ON wt hp; wt WITH hp " # check and return cat(parseMplus(test), file=stdout(), fill=TRUE)#>#>#>#> #> MODEL: #> mpg ON wt hp; #> wt WITH hp #>#>#>#>#> #> MODEL: #> mpg ON wt hp; #> wt WITH hp; #># 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())#>#> #> MODEL: #> mpg cyl disp hp drat wt qsec vs am gear PWITH cyl disp hp drat wt qsec vs am gear carb;