我在Mac OS上使用R studio,我想使用caret
包进行一些数据分析。但是,caret
取决于rlang
软件包,当我尝试加载caret
软件包时,出现此错误-
> library(caret)
Error: package or namespace load failed for ‘caret’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘rlang’ 0.2.2 is already loaded, but >= 0.3.0.1 is required
In addition: Warning message:
package ‘caret’ was built under R version 3.4.4
我从用户界面中删除了
rlang
程序包,然后尝试再次安装它,但是我遇到了以下问题-> install.packages("rlang")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/rlang_0.3.0.1.tgz'
Content type 'application/x-gzip' length 1074663 bytes (1.0 MB)
==================================================
downloaded 1.0 MB
The downloaded binary packages are in
/var/folders/kh/9lkdq11x3sv56717v0700p_r_16f9p/T//RtmplrCvGX/downloaded_packages
> library(rlang)
Error in value[[3L]](cond) :
Package ‘rlang’ version 0.2.2 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘rlang’ is imported by ‘tidyr’, ‘purrr’, ‘ggplot2’, ‘plotly’, ‘dplyr’, ‘tibble’, ‘pillar’ so cannot be unloaded
In addition: Warning message:
package ‘rlang’ was built under R version 3.4.4
这是我的
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14
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.4/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] dummies_1.5.6 ISLR_1.2 mltools_0.3.5 data.table_1.10.4-3 ggplot2_3.0.0.9000 lattice_0.20-35
loaded via a namespace (and not attached):
[1] reshape2_1.4.3 purrr_0.2.4 colorspace_1.3-2 htmltools_0.3.6 viridisLite_0.3.0 yaml_2.1.16 plotly_4.8.0
[8] rlang_0.3.0.1 ModelMetrics_1.2.2 pillar_1.1.0 glue_1.2.0 withr_2.1.2 bindrcpp_0.2 foreach_1.4.4
[15] bindr_0.1 plyr_1.8.4 stringr_1.2.0 munsell_0.5.0 gtable_0.2.0 htmlwidgets_1.2 devtools_1.13.4
[22] codetools_0.2-15 memoise_1.1.0 curl_3.1 Rcpp_0.12.18 scales_1.0.0 jsonlite_1.5 digest_0.6.16
[29] stringi_1.1.6 dplyr_0.7.4 grid_3.4.3 tools_3.4.3 magrittr_1.5 lazyeval_0.2.1 tibble_1.4.2
[36] tidyr_0.7.2 pkgconfig_2.0.1 Matrix_1.2-12 assertthat_0.2.0 httr_1.3.1 iterators_1.0.10 R6_2.2.2
[43] nlme_3.1-131 compiler_3.4.3 git2r_0.21.0
最佳答案
也许尝试一下-删除rlang
,关闭并重新启动R,然后重新安装`rlang'。
如果您仍要安装rlang
的特定版本,
1)转到https://cran.r-project.org/src/contrib/Archive/rlang/
2)获取所需的特定版本的URL。 (在Chrome上,右键单击-复制URL等)
3)启动R,install.packages("[URL]", repo=NULL, type="source")
例如install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_0.2.2.tar.gz", repo=NULL, type="source")