Learn R Programming

MplusAutomation (version 1.1.1)

createSyntax: Create the Mplus input text for an mplusObject

Description

This function takes an object of class mplusObject and creates the Mplus input text corresponding to it, including data link and variable names.

Usage

createSyntax(object, filename, check = TRUE, add = FALSE, imputed = FALSE)

Value

A character string containing all the text for the Mplus input file.

Arguments

object

An object of class mplusObject

filename

The name of the data file as a character vector

check

A logical indicating whether or not to run parseMplus on the created input file. Checks for errors like lines that are too long, or for missing semi-colons and gives notes.

add

A logical passed on to parseMplus whether to add semi colons to line ends. Defaults to FALSE.

imputed

A logical whether the data are multiply imputed. Defaults to FALSE.

Author

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

See Also

prepareMplusData, mplusModeler

Examples

Run this code
# example mplusObject
example1 <- mplusObject(MODEL = "mpg ON wt;",
  usevariables = c("mpg", "hp"), rdata = mtcars)

# create the Mplus input text
cat(createSyntax(example1, "example1.dat"), file=stdout(), fill=TRUE)

# update the object, then create input text
cat(createSyntax(update(example1,
  TITLE = ~ "This is my title;",
  MODEL = ~ . + "\nmpg ON hp;",
  usevariables = c("mpg", "hp", "wt")), "example1.dat"),
  file=stdout(),
  fill=TRUE)
rm(example1)

Run the code above in your browser using DataLab