Generating Data in Mplus and Analyzing them in R

87 views
Skip to first unread message

Dora

unread,
May 24, 2021, 6:37:14 PM5/24/21
to MplusAutomation
Hi there,

I generated a simulation data with 1000 replication for each cell. I want to analyze them in r using mplusautomation and lavaan. How can I make R read the 1000 data for each cell?

Thanks

Josué Almansa

unread,
May 25, 2021, 1:13:35 PM5/25/21
to MplusAutomation
I guess you can  save the Mplus generated data into a text file, read the data in R as 'matrix' or data.frame, and then you may need to do some data-manageent to transform it into a 'list' structure. R usually works with the different imputed datasets in a list.
I don't know if there is a MplusAutomation function that do this, but you can do it yourself with just small amount of programming.

Op dinsdag 25 mei 2021 om 00:37:14 UTC+2 schreef Dora:

michael.hallquist

unread,
Jun 3, 2021, 10:46:10 AM6/3/21
to MplusAutomation
Hi Dora,

This is outside the scope of what the MplusAutomation package is specifically intended to accomplish. That said, I would take a look at list.files() and lapply() in base R, and rbindlist() and fread() in the data.table package. If you put those together, it's easy to read and combine large numbers of files. Something like this:

flist <- list.files(path=getwd())
res <- data.table::rbindlist(lapply(flist, data.table::fread))

Hope that helps,
Michael
Reply all
Reply to author
Forward
0 new messages