cjvanlissa / tidySEM

54 stars 7 forks source link

Using `plot_profiles()` on results of `mx_profiles()` #50

Closed marklhc closed 1 year ago

marklhc commented 2 years ago

Hi,

I see that objects returned by mx_profiles has a class mixture_list, and there is a plot_profiles() method for this class, but I got an error when trying to use plot_profiles(). I'm not sure whether the error is because of the way I applied the function or a bug in the function, as I couldn't find an example in plot_profiles(), but here's a reproducible example of the error I got:

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)
data("empathy")
df <- empathy[1:6]
mx_profiles(data = df,
            classes = 1:2) -> res
#> Running mix1 with 12 parameters
#> Running mix2 with 19 parameters
#> Running mix2 with 19 parameters
class(res)
#> [1] "mixture_list" "mixture_list" "list"
plot_profiles(res)
#> Error in guess(varying): failed to guess time-varying variables from their names

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

Thank you very much!

Mark

maugavilla commented 2 years ago

Mark

I am working on a fix for the full issue, and allowing to present the subject points. But for now you can get the class summary information by adding these arguments

plot_profiles(res, variables=colnames(df), rawdata = F)