write.mplus: Write Mplus Data File

View source: R/write.mplus.R

write.mplusR Documentation

Write Mplus Data File

Description

This function writes a matrix or data frame to a tab-delimited file without variable names, a Mplus input template, and a text file with variable names. Note that only numeric variables are allowed, i.e., non-numeric variables will be removed from the data set. Missing data will be coded as a single numeric value.

Usage

write.mplus(x, file = "Mplus_Data.dat", input = TRUE, n.var = 8,
            var = FALSE, na = -99, check = TRUE)

Arguments

x

a matrix or data frame to be written to a tab-delimited file.

file

a character string naming a file with or without the file extension '.dat', e.g., "Mplus_Data.dat" or "Mplus_Data".

input

logical: if TRUE (default), Mplus input template is written in a text file named according to the argumentfile with the extension _INPUT.inp.

n.var

a numeric value indicating the number of variables in each line under NAMES ARE in the the Mplus input template.

var

logical: if TRUE, variable names are written in a text file named according to the argumentfile with the extension _VARNAMES.txt.

na

a numeric value or character string representing missing values (NA) in the data set.

check

logical: if TRUE, argument specification is checked.

Value

None.

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Muthen, L. K., & Muthen, B. O. (1998-2017). Mplus User's Guide (8th ed.). Muthen & Muthen.

See Also

read.mplus, run.mplus

Examples

## Not run: 
# Write Mplus Data File and a Mplus input template
write.mplus(mtcars)

# Write Mplus Data File "mtcars.dat" and a Mplus input template "mtcars_INPUT.inp",
# missing values coded with -999, 4 variables in each line under "NAMES ARE"
# write variable names in a text file called "mtcars_VARNAMES.inp"
write.mplus(mtcars, file = "mtcars.dat", n.var = 4, var = TRUE, na = -999)

## End(Not run)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to write.mplus in misty...