Hello,
in some R sessions, method dispatch for objects of the (S4) class ?lavaan"
fail. An example from such a ?bad? session:
> library(lavaan)
> HS.model <- ' visual =~ x1 + x2 + x3
+ textual =~ x4 + x5 + x6
+ speed =~ x7 + x8 + x9 '> fit <- cfa(HS.model, data = HolzingerSwineford1939)
> vcov(fit)
Error in UseMethod("vcov") :
no applicable method for 'vcov' applied to an object of class
?lavaan"
But everything _seems_ to be fine:
> selectMethod("vcov", list("lavaan"))
[?]
<environment: namespace:lavaan>
Signatures:
object
target "lavaan"
defined ?lavaan"
> pryr::method_from_call(vcov(fit))
[?]
<environment: namespace:lavaan>
Signatures:
object
target "lavaan"
defined ?lavaan?
For other calls, R uses the default method instead of the one for lavaan,
leading to other errors:
> coef(fit)
Error: $ operator not defined for this S4 class> traceback()
2: coef.default(fit)
1: coef(fit)
Here too, selectMethod() seems to indicate that everything is fine.
As I mentioned, this happens in ?some? R sessions, but I haven?t been able no
narrow down what distinguishes ?bad? from ?good? sessions (where the problem
does not occur). I?ve tried starting with a new session with just package lavaan
loaded (where it works) and then one by one loading the same packages I have
loaded in a bad session, but I can?t reproduce the error in the new session.
Some time ago, somebody posted this problem to the lavaan Google group, but
nothing came of it (https://groups.google.com/forum/#!topic/lavaan/LoUemqNhXBM).
My hope is that somebody here will have an idea for investigating this problem
further.
Thanks a lot in advance,
Uli
Session info from a bad session with almost all objects removed from the
workspace and restarted with only lavaan package loaded:
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK:
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lavaan_0.6-5
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 rstudioapi_0.10 knitr_1.25 magrittr_1.5
tidyselect_0.2.5
[6] mnormt_1.5-5 pbivnorm_0.6.0 R6_2.4.0 rlang_0.4.1
stringr_1.4.0
[11] dplyr_0.8.3 globals_0.12.4 tools_3.6.1 parallel_3.6.1
xfun_0.10
[16] htmltools_0.4.0 assertthat_0.2.1 digest_0.6.22 tibble_2.1.3
crayon_1.3.4
[21] pryr_0.1.4 purrr_0.3.3 codetools_0.2-16 glue_1.3.1
stringi_1.4.3
[26] compiler_3.6.1 pillar_1.4.2 stats4_3.6.1 future_1.15.0
listenv_0.7.0
[31] pkgconfig_2.0.3
Session info from a good session with lots of packages loaded while trying to
reproduce the problem:
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS:
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK:
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] future_1.15.0 rlang_0.4.1 magrittr_1.5
TAM_3.3-10
[5] CDM_7.4-19 mvtnorm_1.0-11 semPlot_1.1.2
MplusAutomation_0.7-3
[9] forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
purrr_0.3.3
[13] readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
ggplot2_3.2.1
[17] tidyverse_1.2.1 psych_1.8.12 semTools_0.5-2
lavaan_0.6-5
loaded via a namespace (and not attached):
[1] minqa_1.2.4 colorspace_1.4-1 rjson_0.2.20
htmlTable_1.13.2
[5] corpcor_1.6.9 base64enc_0.1-3 rstudioapi_0.10 listenv_0.7.0
[9] lubridate_1.7.4 xml2_1.2.2 codetools_0.2-16 splines_3.6.1
[13] mnormt_1.5-5 knitr_1.25 glasso_1.11 texreg_1.36.23
[17] zeallot_0.1.0 Formula_1.2-3 jsonlite_1.6 nloptr_1.2.1
[21] broom_0.5.2 cluster_2.1.0 png_0.1-7 regsem_1.3.9
[25] compiler_3.6.1 httr_1.4.1 backports_1.1.5
assertthat_0.2.1
[29] Matrix_1.2-17 lazyeval_0.2.2 cli_1.1.0 acepack_1.4.1
[33] htmltools_0.4.0 tools_3.6.1 OpenMx_2.14.11 igraph_1.2.4.1
[37] coda_0.19-3 gtable_0.3.0 glue_1.3.1 reshape2_1.4.3
[41] Rcpp_1.0.3 carData_3.0-2 cellranger_1.1.0 vctrs_0.2.0
[45] nlme_3.1-142 lisrelToR_0.1.4 xfun_0.10 globals_0.12.4
[49] proto_1.0.0 openxlsx_4.1.3 lme4_1.1-21 rvest_0.3.5
[53] ggm_2.3 lifecycle_0.1.0 gtools_3.8.1 XML_3.98-1.20
[57] MASS_7.3-51.4 scales_1.0.0 BDgraph_2.61 hms_0.5.2
[61] kutils_1.69 parallel_3.6.1 huge_1.3.4
RColorBrewer_1.1-2
[65] pbapply_1.4-2 gridExtra_2.3 pander_0.6.3 rpart_4.1-15
[69] latticeExtra_0.6-28 stringi_1.4.3 sem_3.1-9
checkmate_1.9.4
[73] polycor_0.7-10 boot_1.3-23 zip_2.0.4
truncnorm_1.0-8
[77] d3Network_0.5.2.1 pkgconfig_2.0.3 Rsolnp_1.16 arm_1.10-1
[81] lattice_0.20-38 htmlwidgets_1.5.1 tidyselect_0.2.5 plyr_1.8.4
[85] R6_2.4.0 generics_0.0.2 Hmisc_4.3-0 whisker_0.4
[89] gsubfn_0.7 pillar_1.4.2 haven_2.2.0 foreign_0.8-72
[93] withr_2.1.2 rockchalk_1.8.144 survival_3.1-7 abind_1.4-5
[97] nnet_7.3-12 modelr_0.1.5 crayon_1.3.4 fdrtool_1.2.15
[101] jpeg_0.1-8.1 grid_3.6.1 readxl_1.3.1 qgraph_1.6.3
[105] data.table_1.12.6 pbivnorm_0.6.0 matrixcalc_1.0-3 digest_0.6.22
[109] xtable_1.8-4 mi_1.0 stats4_3.6.1 munsell_0.5.0