R语言---Ubuntu中R语言更新至R4.2.1和R包devtools下载
R語言---Ubuntu中R語言更新至R4.2
- 1. Ubuntu18.04升級R語言至R4.2
- (1)更新下載地址
- (2)sudo下載
- 2. 重新下載R包
- (1)只更新Bioconductor包
- (2)更新所有包
- 3. R包devtools下載
- 4. 總結
時間: 2022-10-23
1. Ubuntu18.04升級R語言至R4.2
進入R官網(https://cloud.r-project.org/)進入ubuntu下載頁面,或者直接搜索Ubuntu Packages For R - Brief Instructions進入。
(1)更新下載地址
# update indices sudo apt update -qq# install two helper packages we need sudo apt install --no-install-recommends software-properties-common dirmngr# add the signing key (by Michael Rutter) for these repos # To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9 wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"(2)sudo下載
下載最新版本R語言
sudo apt install --no-install-recommends r-base使用上面的參數只下載必要的依賴文件:
詳細版本的R更新可以查看:
https://cloud.r-project.org/bin/linux/ubuntu/fullREADME.html2. 重新下載R包
(1)只更新Bioconductor包
以ComplexHeatmap為例:
https://www.bioconductor.org/packages/release/bioc/html/ComplexHeatmap.html發現現在的頁面版本是Bioconductor version: Release (3.15),不確定版本可以使用下面嘗試加載命令,會提示正確版本信息:
if (!require("BiocManager", quietly = TRUE))install.packages("BiocManager")隨后更新BiocManager版本至3.15,此時就會更新所有的Bioconductor包(比較費時):
BiocManager::install(version = '3.15')(2)更新所有包
更新CRAN, Bioconductor和Github上的R包:
require(rvcheck) update_all()可以考慮將該命令放入系統中,每個月或幾個月更新一次,實現R包更新自動化,不必每次手動檢查了:
rvcheck::update_all()3. R包devtools下載
為了更好的使用Github中的R包,需要下載devtools以此來獲得Github中的野包(未被CRAN收錄):
打開R4.2.1,下載devtools:
該軟件包含很多依賴包,下載到后面出現報錯:
usethis R包不能安裝,提示gert這個依賴包不能安裝。仔細看報錯信息,看Ubuntu那行原來是缺少系統文件:
Configuration failed to find libgit2 library. Try installing:* brew: libgit2 (MacOS)* deb: libgit2-dev (Debian, Ubuntu, etc)* rpm: libgit2-devel (Fedora, CentOS, RHEL)下載系統文件:
sudo apt install libgit2-dev繼續下載遇到同樣的錯誤,看Ubuntu那行原來是缺少系統文件:
Configuration failed to find the harfbuzz freetype2 fribidi library. Try installing:* deb: libharfbuzz-dev libfribidi-dev (Debian, Ubuntu, etc)* rpm: harfbuzz-devel fribidi-devel (Fedora, EPEL)* csw: libharfbuzz_dev libfribidi_dev (Solaris)* brew: harfbuzz fribidi (OSX) If harfbuzz freetype2 fribidi is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a harfbuzz freetype2 fribidi.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' -------------------------- [ERROR MESSAGE] --------------------------- <stdin>:1:10: fatal error: hb-ft.h: 沒有那個文件或目錄 compilation terminated. -------------------------------------------------------------------- ERROR: configuration failed for package ‘textshaping’ * removing ‘/home/cfc424/R/x86_64-pc-linux-gnu-library/4.2/textshaping’下載的程序包在‘/tmp/RtmpBDL8b7/downloaded_packages’里 Warning message: In install.packages("textshaping") :下載系統文件:
sudo apt install libharfbuzz-dev libfribidi-dev再次運行install.packages("devtools"),順利完成,成功安裝devtools。
4. 總結
R語言版本和R包版本是要常常更新的,否則時間長了,容易出現軟件安裝無法安裝依賴包情況,這個時候,如果軟件依賴過多,就只能重新下載R語言了,不必折騰過老的R版本,毫無價值。
有點問題,還是存在一些包版本未升級,只能用的時候自己update一下了。
參考:
https://cloud.r-project.org/ (R官網)
https://cloud.r-project.org/bin/linux/ubuntu/fullREADME.html (下載R和R包全文檔)
https://github.com/r-lib/textshaping/issues/21 (devtools安裝中報錯查詢)
https://askubuntu.com/questions/65081/what-are-the-implications-of-no-install-recommends-apt-get-install
總結
以上是生活随笔為你收集整理的R语言---Ubuntu中R语言更新至R4.2.1和R包devtools下载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jQuery ajax 和 普通js a
- 下一篇: ubuntu18.04安装pycharm