R语言3.6版本安装ggplot2报错解决方法 | 您所在的位置:网站首页 › ggplot安装不上 › R语言3.6版本安装ggplot2报错解决方法 |
文章目录
1. ggplot2包安装报错2,安装rlange1.0.03. 安装Rtools3.64. 重新安装ggplot25. 安装ellipsis包6. 安装pillar包7. 重新安装ggplot28. 测试成功安装ggplot2
现在最新的R版本是4.2.1,因为有些包只能运行在3.6版本中,因此我需要安装3.6,这里安装常用的ggplot2时报错了,总结一下问题解决的方法。 1. ggplot2包安装报错报错如下: ** byte-compile and prepare package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : namespace 'rlang' 0.4.11 is already loaded, but >= 1.0.2 is required Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace 停止执行 ERROR: lazy loading failed for package 'pillar' * removing 'C:/Users/dave/Documents/R/win-library/3.6/pillar' Warning in install.packages : installation of package ‘pillar’ had non-zero exit status * installing *source* package 'scales' ... ** 成功将'scales'程序包解包并MD5和检查 ** using staged installation ** R ** byte-compile and prepare package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : namespace 'rlang' 0.4.11 is being loaded, but >= 1.0.0 is required Calls: ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace 停止执行 ERROR: lazy loading failed for package 'scales' * removing 'C:/Users/dave/Documents/R/win-library/3.6/scales' Warning in install.packages : installation of package ‘scales’ had non-zero exit status ERROR: dependency 'scales' is not available for package 'ggplot2' * removing 'C:/Users/dave/Documents/R/win-library/3.6/ggplot2' Warning in install.packages : installation of package ‘ggplot2’ had non-zero exit status The downloaded source packages are in ‘C:\Users\dave\AppData\Local\Temp\Rtmpg3apRU\downloaded_packages’看起来,主要是因为rlange这个包版本太低,应该是大于1.0.0,现在是0.4.11. 2,安装rlange1.0.0如果现在网上搜索R包的地址,包括其不同的版本,可以键入: https://cran.r-project.org/src/contrib/Archive/ 如果知道包的名称,比如ggplot2,键入: https://cran.r-project.org/src/contrib/Archive/ggplot2 包的链接: https://cran.r-project.org/src/contrib/Archive/rlang/rlang_1.0.1.tar.gz 命令: install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_1.0.1.tar.gz", repo=NULL, type="source")报错: * installing *source* package 'rlang' ... ** 成功将'rlang'程序包解包并MD5和检查 ** using staged installation ** libs Warning in system(cmd) : 'make' not found ERROR: compilation failed for package 'rlang' * removing 'C:/Users/dave/Documents/R/win-library/3.6/rlang' * restoring previous 'C:/Users/dave/Documents/R/win-library/3.6/rlang' Warning in install.packages : installation of package ‘C:/Users/dave/AppData/Local/Temp/Rtmpg3apRU/downloaded_packages/rlang_1.0.1.tar.gz’ had non-zero exit status 3. 安装Rtools3.6尝试安装Rtools3.6,重启R语言,然后键入: install.packages("https://cran.r-project.org/src/contrib/Archive/rlang/rlang_1.0.1.tar.gz", repo=NULL, type="source")成功: vector-construction html vector-old-ctors html with_env html with_handlers html wref_key html zap html zap_srcref html *** copying figures ** building package indices ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (rlang)测试: > library(rlang) > sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) Matrix products: default locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 [2] LC_CTYPE=Chinese (Simplified)_China.936 [3] LC_MONETARY=Chinese (Simplified)_China.936 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.936 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rlang_1.0.1 loaded via a namespace (and not attached): [1] compiler_3.6.3 cli_2.5.0 tools_3.6.3可以看到,上面的R版本是3.6.3,rlang的版本是1.0.1,搞定。 4. 重新安装ggplot2 install.packages("ggplot2")报错: ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'ellipsis' Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart 停止执行 ERROR: lazy loading failed for package 'ggplot2' * removing 'C:/Users/dave/Documents/R/win-library/3.6/ggplot2' Warning in install.packages : installation of package ‘ggplot2’ had non-zero exit status看到,是因为没有ellipsis这个包,那就单独安装试试。 5. 安装ellipsis包 install.packages("ellipsis")安装成功: > install.packages("ellipsis") Installing package into ‘C:/Users/dave/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified) trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.6/ellipsis_0.3.2.zip' Content type 'application/zip' length 49192 bytes (48 KB) downloaded 48 KB package ‘ellipsis’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\dave\AppData\Local\Temp\RtmpWqZTPD\downloaded_packages再重新安装ggplot2: install.packages("ggplot2")报错: ** byte-compile and prepare package for lazy loading Error in loadNamespace(j withRestarts -> withOneRestart -> doWithOneRestart 停止执行 ERROR: lazy loading failed for package 'ggplot2' * removing 'C:/Users/dave/Documents/R/win-library/3.6/ggplot2' Warning in install.packages : installation of package ‘ggplot2’ had non-zero exit status 6. 安装pillar包继续安装pillar,编译安装,安装成功后,继续安装ggplot2,如果哪个包报错,就安装哪个包。 7. 重新安装ggplot2安装成功: *** copying figures ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (ggplot2) The downloaded source packages are in ‘C:\Users\dave\AppData\Local\Temp\RtmpMhrQc1\downloaded_packages’ 8. 测试成功安装ggplot2测试: > library(ggplot2) > sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) Matrix products: default locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 [2] LC_CTYPE=Chinese (Simplified)_China.936 [3] LC_MONETARY=Chinese (Simplified)_China.936 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.936 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_3.3.6 loaded via a namespace (and not attached): [1] fansi_0.4.2 withr_2.5.0 utf8_1.2.1 grid_3.6.3 [5] R6_2.5.1 lifecycle_1.0.1 gtable_0.3.0 magrittr_2.0.1 [9] scales_1.2.1 pillar_1.8.1 rlang_1.0.4 cli_2.5.0 [13] vctrs_0.3.8 ellipsis_0.3.2 tools_3.6.3 glue_1.4.2 [17] munsell_0.5.0 compiler_3.6.3 pkgconfig_2.0.3 colorspace_2.0-1 [21] tibble_3.1.1可以看到,我的R版本是3.6.3,ggplot2的版本是3.3.6,搞定! |
CopyRight 2018-2019 实验室设备网 版权所有 |