cjvanlissa / tidySEM

54 stars 7 forks source link

Error in the example for `plot_density()` #48

Closed marklhc closed 2 years ago

marklhc commented 2 years ago

Hi,

Thank you for making this package, which makes running mixture models in R much easier for me. I was trying to learn from the example of plot_density() but ran into an error:

library(tidySEM)
#> Loading required package: OpenMx
#> To take full advantage of multiple cores, use:
#>   mxOption(key='Number of Threads', value=parallel::detectCores()) #now
#>   Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
dat <-
  iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
names(dat) <- paste0("x", 1:4)
res <- mx_profiles(dat, 1:3)
#> Running mix1 with 8 parameters
#> Running mix2 with 13 parameters
#> Running mix2 with 13 parameters
#> Running mix3 with 18 parameters
#> Running mix3 with 18 parameters
plot_density(res)
#> Error in x[[1]]@submodels[[1]]: subscript out of bounds

Created on 2022-05-18 by the reprex package (v2.0.1)

Do you have an idea why I'm getting this error? Thank you very much. I'm using the latest version of the package on GitHub and R 4.2.0.

Best,

Mark

maugavilla commented 2 years ago

Hi Mark

I just push to github a fix for this error. It works fine for me with the new github version

take care