首页 > 解决方案 > R 为 semPlot 和 semPath 抛出错误

问题描述

更新:这个问题似乎是 Mac 独有的

semPlot 的安装似乎很顺利,但是当我调用库时,它会抛出一个关于未找到包“glasso”的错误。当我尝试使用 semPath 时,它说找不到该函数。

无数次重启了RStudio。R 和我的电脑一样是最新的(MacOS Mojave 版本 10.14.6)。

我在较早的帖子中尝试了有关重新启动 RStudio,然后再次安装并安装 XML 的解决方案,但这也不起作用。我包含了依赖项参数以确保它已完全安装,尽管我认为这与它没有任何关系。代码如下,包括会话信息。

install.packages("semPlot", dependencies = TRUE)
library(semPlot)
semPaths(aa.cfa.fitted)
sessionInfo()

输出如下:

> install.packages("semPlot", dependencies = TRUE)
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/semPlot_1.1.2.tgz'
Content type 'application/x-gzip' length 344192 bytes (336 KB)
==================================================
downloaded 336 KB


The downloaded binary packages are in
    /var/folders/9b/fg1p3n5j3_d8wvtpwz1_tvx00000gn/T//RtmpyOIMa0/downloaded_packages
> library(semPlot)
Error: package or namespace load failed for ‘semPlot’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 there is no package called ‘glasso’
> semPaths(aa.cfa.fitted)
Error in semPaths(aa.cfa.fitted) : could not find function "semPaths"
> 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

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

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  
[7] base     

other attached packages:
[1] GPArotation_2014.11-1 nFactors_2.3.3.1     
[3] lattice_0.20-38       boot_1.3-23          
[5] MASS_7.3-51.4         psych_1.8.12         
[7] lavaan_0.6-5         

loaded via a namespace (and not attached):
 [1] splines_3.6.1       carData_3.0-2       Formula_1.2-3      
 [4] BDgraph_2.61        stats4_3.6.1        latticeExtra_0.6-28
 [7] lisrelToR_0.1.4     pbivnorm_0.6.0      pillar_1.4.2       
[10] backports_1.1.4     digest_0.6.21       RColorBrewer_1.1-2 
[13] checkmate_1.9.4     minqa_1.2.4         colorspace_1.4-1   
[16] htmltools_0.3.6     Matrix_1.2-17       plyr_1.8.4         
[19] XML_3.98-1.20       pkgconfig_2.0.3     xtable_1.8-4       
[22] corpcor_1.6.9       scales_1.0.0        jpeg_0.1-8         
[25] openxlsx_4.1.0.1    fdrtool_1.2.15      lme4_1.1-21        
[28] arm_1.10-1          tibble_2.1.3        htmlTable_1.13.2   
[31] rockchalk_1.8.144   ggplot2_3.2.1       nnet_7.3-12        
[34] lazyeval_0.2.2      mnormt_1.5-5        magrittr_1.5       
[37] survival_2.44-1.1   crayon_1.3.4        kutils_1.69        
[40] nlme_3.1-141        foreign_0.8-72      truncnorm_1.0-8    
[43] regsem_1.3.9        data.table_1.12.2   tools_3.6.1        
[46] stringr_1.4.0       munsell_0.5.0       cluster_2.1.0      
[49] zip_2.0.4           compiler_3.6.1      sem_3.1-9          
[52] rlang_0.4.0         grid_3.6.1          nloptr_1.2.1       
[55] rstudioapi_0.10     htmlwidgets_1.3     igraph_1.2.4.1     
[58] Rsolnp_1.16         base64enc_0.1-3     mi_1.0             
[61] gtable_0.3.0        abind_1.4-5         reshape2_1.4.3     
[64] gridExtra_2.3       knitr_1.25          Hmisc_4.2-0        
[67] stringi_1.4.3       matrixcalc_1.0-3    parallel_3.6.1     
[70] Rcpp_1.0.2          rpart_4.1-15        acepack_1.4.1      
[73] png_0.1-7           xfun_0.10           coda_0.19-3        

标签: rsemplot

解决方案


先安装glasso怎么样?

install.packages("glasso")
install.packages("semPlot")

我认为这应该可以解决它(抱歉,没有 MacOS 可以测试)。


推荐阅读