Learn R Programming

MplusAutomation (version 1.1.1)

.convertData: Convert a matrix or data frame to numeric or integer for Mplus

Description

Primarily an internal utility function, for prepareMplusData.

Usage

.convertData(df, dummyCode = NULL)

Value

An error if it cannot be converted or a matrix or data frame with all variables converted to numeric or integer classes

Arguments

df

A matrix or data frame

Examples

Run this code

if (FALSE) {
df1 <- df2 <- df3 <- df4 <- mtcars

df2$cyl <- factor(df2$cyl)
df2$am <- as.logical(df2$am)

df3$mpg <- as.character(df3$mpg)

df4$vs <- as.Date(df4$vs, origin = "1989-01-01")

df5 <- as.matrix(cars)

df6 <- matrix(c(TRUE, TRUE, FALSE, FALSE), ncol = 2)

df7 <- as.list(mtcars)


MplusAutomation:::.convertData(df1)

MplusAutomation:::.convertData(df2)

MplusAutomation:::.convertData(df3)

MplusAutomation:::.convertData(df4)

MplusAutomation:::.convertData(df5)

MplusAutomation:::.convertData(df6)

MplusAutomation:::.convertData(df7)

rm(df1, df2, df3, df4, df5, df6, df7)
}

Run the code above in your browser using DataLab