prepareMplusData: Create tab-delimited file and Mplus input syntax from R...

Description Usage Arguments Value Author(s) Examples

View source: R/createModels.R

Description

The prepareMplusData function converts an R data.frame object into a tab-delimited file (without header) to be used in an Mplus input file. The corresponding Mplus syntax, including the data file definition and variable names, is printed to the console.

Usage

1
2
prepareMplusData(df, filename, keepCols, dropCols, inpfile=FALSE,
  interactive=TRUE, overwrite=TRUE)

Arguments

df

The R data.frame to be prepared for Mplus

filename

The path and filename for the tab-delimited data file for use with Mplus. Example: "C:/Mplusdata/data1.dat"

keepCols

A character vector specifying the variable names within df to be output to filename.

dropCols

A character vector specifying the variable names within df to be omitted from the data output to filename.

inpfile

Logical value whether the Mplus syntax should be written to the console or to an input file. Defaults to FALSE. If TRUE, the file name will be the same as filename with the extension changed to .inp. Alternately, this can be a character string giving the file name to write the Mplus syntax to.

interactive

Logical value indicating whether file names should be selected interactively. If filename is missing and interative=TRUE, then a dialog box will pop up to select a file or a console prompt if in a non-interactive context. Defaults to TRUE.

overwrite

Logical value indicating whether data and input (if present) files should be overwritten. Defaults to TRUE to be consistent with prior behavior. If FALSE and the file to write the data to already exists, it will throw an error.

Value

No value is returned by this function. It is solely used to convert an R data.frame to an Mplus data file.

Author(s)

Michael Hallquist

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
library(foreign)

study5 <- read.spss("reanalysis-study-5-mt-fall-08.sav", to.data.frame=TRUE)
ASData5 <- subset(study5, select=c("ppnum", paste("as", 1:33, sep="")))

prepareMplusData(ASData5, "study5.dat")

## End(Not run)

MplusAutomation documentation built on May 2, 2019, 5:55 p.m.