Learn R Programming

misty (version 0.4.0)

write.mplus: Write Mplus Data File

Description

This function writes a matrix or data frame to a tab-delimited file without variable names and a text file with variable names. Only numeric values are allowed, missing data will be coded as a single numeric value.

Usage

write.mplus(x, file = "Mplus_Data.dat", var = TRUE, print = 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".

var

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

print

logical: if TRUE, variable names are printed on the console.

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.

References

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

See Also

read.mplus, run.mplus

Examples

Run this code
# NOT RUN {
dat <- data.frame(id = 1:5,
                  x = c(NA, 2, 1, 5, 6),
                  y = c(5, 3, 6, 8, 2),
                  z = c(2, 1, 1, NA, 4), stringsAsFactors = FALSE)

# Write Mplus Data File and a text file with variable names
write.mplus(dat)

# Write Mplus Data File "Data.dat" and a text file with variable name,
# print variable names on the console, missing values coded with -999
write.mplus(dat, file = "Data.dat", print = TRUE, na = -999)
# }

Run the code above in your browser using DataLab