久久精品精选,精品九九视频,www久久只有这里有精品,亚洲熟女乱色综合一区
    分享

    舊版本的R3.6安裝最新版的ggplot2

     育種數據分析 2022-08-24 發布于河南

    本來我這個段位,就不應該為安裝包發愁了,畢竟統計學不會可以理解,編程學不好忍忍就過去了,但是說安裝包出錯,是可忍孰不可忍?

    統計編程我惹不起就算了,你一個安裝包我還搞不定了???

    事實證明,包還是非常難安裝的,一邊安裝,一邊想著,一些收費的軟件是有原因的……

    目錄:

    • 1. ggplot2包安裝報錯

    • 2,安裝rlange1.0.0

    • 3. 安裝Rtools3.6

    • 4. 重新安裝ggplot2

    • 5. 安裝ellipsis包

    • 6. 安裝pillar包

    • 7. 重新安裝ggplot2

    • 8. 測試成功安裝ggplot2

    現在最新的R版本是4.2.1,因為有些包只能運行在3.6版本中,因此我需要安裝3.6,這里安裝常用的ggplot2時報錯了,總結一下問題解決的方法。

    1. ggplot2包安裝報錯

    本來,我安裝R3.6,然后直接運行install.packages("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: <Anonymous> ... 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: <Anonymous> ... 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。問題來了,我有兩個選擇:

    第一個:下載舊版本的ggplot2,它支持rlang0.4.11版本,但是很多更新的函數我無法使用了。測試了一下,可以實現。但我要用第二個。

    第二個:下載rlang1.0,然后安裝最新版的ggplot2,這條路很曲折,但是解決好之后就可以用最新的版本了,也算物有所值了。

    用第二個,搞起!

    2,安裝rlange1.0.0

    如果現在網上搜索R包的地址,包括其不同的版本,可以鍵入: 

    https://cran./src/contrib/Archive/

    如果知道包的名稱,比如ggplot2,鍵入:

    https://cran./src/contrib/Archive/ggplot2

    可以看到,舊版本的ggplot2,下載到本地,然后安裝就可以了。這里我們不用這種方法,我們要安裝最新版的。

    在這里插入圖片描述

    找到rlang包的鏈接:https://cran./src/contrib/Archive/rlang/rlang_1.0.1.tar.gz

    然后復制包的鏈接,運行下面命令:

    install.packages("https://cran./src/contrib/Archive/rlang/rlang_1.0.1.tar.gz", repo=NULL, type="source")

    相當于將包下載到本地安裝,這里報錯了,顯示我沒有make命令。

    所以,我要安裝編譯的工具Rtools。

    * 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./src/contrib/Archive/rlang/rlang_1.0.1.tar.gz", repo=NULL, type="source")

    成功,可以看到rlang1.0安裝好了,重新本地編譯安裝是可以解決問題的。

        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")

    安裝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: <Anonymous> ... 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./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")

    還是報錯,顯示pillar包沒有安裝好,那就繼續單獨安裝。

    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
      there is no package called 'pillar'
    Calls: <Anonymous> ... 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

    6. 安裝pillar包

    繼續安裝pillar,編譯安裝,安裝成功后,繼續安裝ggplot2,如果哪個包報錯,就安裝哪個包。

    安裝好之后,再安裝ggplot2,如果還有包報錯,就單獨安裝。

    一路走來,哪里報錯安哪里,本來自動化安裝依賴的R語言讓我整成了手動。

    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

    測試,載入,然后看一下R的版本和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,搞定!

    這種方法可以推廣到R3.5,R4.0,R4.1,windows系統安裝Rtools就是為了防止本地編譯時出錯,里面有C,C++,Fortran等各種編譯器,一籃子滿滿的。有了它,就不怕R包安裝了。

    原則上來說,所有的包都可以被成功安裝,多嘗試幾次就行了。

      轉藏 分享 獻花(0

      0條評論

      發表

      請遵守用戶 評論公約

      類似文章 更多

      主站蜘蛛池模板: 午夜福利在线观看6080| 中文字幕无线码免费人妻| 国产激情视频在线观看的| av中文字幕在线二区| 亚洲国产五月综合网| 国内精品自线在拍| 国产69精品久久久久99尤物| 久久婷婷综合色丁香五月| 亚洲国产中文字幕精品| 国产精品福利在线观看无码卡一 | 中文字幕亚洲人妻系列| 成 人 色 网 站免费观看| 国产成人精品999在线观看| 少妇高潮水多太爽了动态图| 少妇高清精品毛片在线视频| 好男人社区在线观看免费视频| 精品人妻伦九区久久AAA片| 亚洲日本韩国欧美云霸高清| 99久久久国产精品消防器材| 成人午夜av在线播放| 丰满无码人妻热妇无码区| 亚洲精品无码成人AV电影网| 久久精品久久电影免费理论片 | 不卡国产一区二区三区| 国产美女MM131爽爽爽| 少妇人妻AV无码专区| 日韩在线成年视频人网站观看| 波多野结衣中文字幕久久| 午夜精品福利亚洲国产| 国产在线无码视频一区二区三区| 国产亚洲精品成人aa片新蒲金| 欧美在线人视频在线观看| 国内精品一区二区三区| 日韩有码中文字幕国产| 欧美XXXX黑人又粗又长| 国产精品中文字幕一区| 国产对白熟女受不了了| 麻豆成人精品国产免费| 国产精品久久久久影院亚瑟| 国产激情艳情在线看视频| 人妻人人做人做人人爱|