michaelhallquist / MplusAutomation

The MplusAutomation package leverages the flexibility of the R language to automate latent variable model estimation and interpretation using Mplus, a powerful latent variable modeling program developed by Muthen and Muthen (www.statmodel.com). Specifically, MplusAutomation provides routines for creating related groups of models, running batches of models, and extracting and tabulating model parameters and fit statistics.
81 stars 46 forks source link

Error vapply(df, class, FUN.VALUE = NA_character_) : values must be length 1, but FUN(X[[1]]) result is length 3 (mplusModeler) #178

Closed ASjoh closed 1 year ago

ASjoh commented 1 year ago

I am using MplusAutomation to run a Latent Class Analysis in R (version 4.2.1), but there's an error occurring with mplusModeler and the function it calls internally (see code below):

library(naniar)
library(tidyverse)
library(haven)
library(glue)
library(MplusAutomation)
library(rhdf5)
library(here)
library(janitor)
library(gt)
library(poLCA)
library(dplyr)
library(janitor)

  TITLE = "BCH lca with distal outcome;", 

  DATA = "LISTWISE=ON;",

  VARIABLE = 
    "usevar = int_3 sw_3 soc_3 alt_3 gov_3 for_3;
    auxiliary = claim_5 claim_6 (bch);
    classes = c(5);",

  ANALYSIS =
    "estimator = mlr;
    type = mixture;
    starts = 500 100;
    processors = 10;",

  OUTPUT = 
    "type = plot3;
    series = int_3 sw_3 soc_3 alt_3 gov_3 for_3(*);",

  usevariables = c("int_3", "sw_3", "soc_3", "alt_3", "gov_3", "for_3", "claim_5", "claim_6"),
  rdata =  data_lca_distal_Mpanel_220918)

m_bch_fit <- mplusModeler(m_bch,
                          dataout=here("paper 2"),
                          modelout=here("paper 2"),
                          check=TRUE, run = TRUE, hashfilename = FALSE)

Specifically, I get the following error message:

_Error in vapply(df, class, FUN.VALUE = NAcharacter) : values must be length 1, but FUN(X[[1]]) result is length 3_

I am rather new to this forum so please let me know if there is any additional information I can provide. I greatly appreciate the help! Thanks, -Sofia