Learn R Programming

misty (version 0.5.0)

read.mplus: Read Mplus Data File and Variable Names

Description

This function reads a Mplus data file and/or Mplus input/output file to return a data frame with variable names extracted from the Mplus input/output file.

Usage

read.mplus(file, sep = "", input = NULL, print = FALSE, return.var = FALSE,
           fileEncoding = "UTF-8-BOM", check = TRUE)

Value

A data frame containing a representation of the data in the file.

Arguments

file

a character string indicating the name of the Mplus data file with or without the file extension .dat, e.g., "Mplus_Data.dat" or "Mplus_Data". Note that it is not necessary to specify this argument when return.var = TRUE.

sep

a character string indicating the field separator (i.e., delimiter) used in the data file specified in file. By default, the separator is 'white space', i.e., one or more spaces, tabs, newlines or carriage returns.

input

a character string indicating the Mplus input (.inp) or output file (.out) in which the variable names are specified in the VARIABLE: section. Note that if input = NULL, this function is equivalent to read.table(file).

print

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

return.var

logical: if TRUE, the function returns the variable names extracted from the Mplus input or output file only.

fileEncoding

character string declaring the encoding used on file so the character data can be re-encoded. See df.sort.

check

logical: if TRUE, argument specification is checked.

Author

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

run.mplus, write.mplus, read.sav, read.xlsx

Examples

Run this code
if (FALSE) {
# Read Mplus data file and variable names extracted from the Mplus input file
dat <- read.mplus("Mplus_Data.dat", input = "Mplus_Input.inp")

# Read Mplus data file and variable names extracted from the Mplus input file,
# print variable names on the console
dat <- read.mplus("Mplus_Data.dat", input = "Mplus_Input.inp", print = TRUE)

# Read variable names extracted from the Mplus input file
varnames <- read.mplus(input = "Mplus_Input.inp", return.var = TRUE)
}

Run the code above in your browser using DataLab