R包安裝及設(shè)置鏡像

安裝包及設(shè)置鏡像

安裝包

安裝CRAN軟件

install.packages(pkgs, lib, repos = getOption("repos"), quiet = FALSE)

lib: character vector giving the library directories where to install the packages. Recycled as needed. If missing, defaults to the first element of .libPaths().
repos: character vector, the base URL(s) of the repositories to use, e.g., the URL of a CRAN mirror such as "https://cloud.r-project.org". For more details on supported URL schemes see url.

quiet: logical: if true, reduce the amount of output.

安裝Bioconductor 相關(guān)包

# Source biocLite from web
source("https://bioconductor.org/biocLite.R")
biocLite("package_name")

# Use biocLite under BiocInstaller
install.packages("BiocInstaller")
BiocInstaller::biocLite("package_name")  

biocLite(pkgs=c("Biobase", "IRanges", "AnnotationDbi"),  
         suppressUpdates=FALSE,
         suppressAutoUpdate=FALSE,
         siteRepos=character(),
         ask=TRUE, ...)

Install or update Bioconductor, CRAN, or GitHub packages

if (!requireNamespace("BiocManager", quietly=TRUE)) 
    install.packages("BiocManager")
BiocManager::install("package_name")

Note: BioInstaller and biocLiteare deprecated use the biocmanager cran package instead.

本地安裝源碼包

install.packages("path/to/pkg/package_name.tar.gz", repos = NULL, type = "source")

源碼編譯安裝的時(shí)候,要將源碼壓縮成tar.gz格式再安裝,zip格式會(huì)出奇怪的錯(cuò)誤。

R包相關(guān)操作

# 查看R包安裝位置
.libPaths()

# 查看已安裝的包
installed.packages()

# 查看包版本
packageVersion("package_name")

# 更新包
update.packages("package_name")

# 加載包
library("package_name")
require("package_name")

# 查看加載的包
.packages()

# 移除已加載的包(將包從R運(yùn)行環(huán)境中移除)
detach("package_name")

# 徹底刪除已安裝的包:
remove.packages("package_name", lib = file.path("path/to/library"))

鏡像設(shè)置

常用鏡像地址

Name URL host type
China (Anhui) [https] https://mirrors.ustc.edu.cn/bioc/ 中科大 CRAN_mirror
China (Anhui) http://mirrors.ustc.edu.cn/bioc/ 中科大 CRAN_mirror
China (Beijing) [https] https://mirrors.tuna.tsinghua.edu.cn/CRAN/ 清華 BioC_mirror
China (Beijing) http://mirrors.tuna.tsinghua.edu.cn/CRAN/ 清華 BioC_mirror

CRAN鏡像下載安裝包

# 從CRAN鏡像下載安裝包
install.packages(pkgs, repos = "https://mirrors.ustc.edu.cn/CRAN/")

# 從BioC鏡像安裝包
biocLite(pkg, siteRepos = "http://mirrors.ustc.edu.cn/bioc/")

常用函數(shù)

# 查看當(dāng)前鏡像地址
getOption("repos")

# 查看R_HOME地址
R.home()

R_HOME/doc/CRAN_mirrors.csv
R_HOME/doc/BioC_mirrors.csv

將鏡像添加到配置文件

Bioconductor 鏡像源配置文件之一是 .Rprofile (linux 下位于 ~/.Rprofile )。

在文末添加如下語(yǔ)句:

options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. pwd: 查看當(dāng)前光標(biāo)所在的路徑 2. home directory: 當(dāng)前用戶所在的默認(rèn)目錄 /r...
    Santi龘閱讀 475評(píng)論 0 0
  • git的學(xué)習(xí)可以參照廖雪峰老師的教程https://www.liaoxuefeng.com/wiki/001373...
    11的霧閱讀 213評(píng)論 0 0
  • 虛擬機(jī)系統(tǒng)啟動(dòng)速度恢復(fù)正常 嘗試啟動(dòng)ossec服務(wù),報(bào)錯(cuò)如下 Starting OSSEC HIDS 3.1.0 ...
    UserL閱讀 1,307評(píng)論 0 1
  • Mac 中配置php環(huán)境問(wèn)題解決 解決Mac下IntelliJ IDEA“php-cgi not found: P...
    泉泉泉泉泉泉閱讀 4,700評(píng)論 1 1
  • 今天又看了一本小說(shuō),書名非常歡快,簡(jiǎn)介也十分詼諧。 但是當(dāng)我看到正文時(shí)才發(fā)現(xiàn),騙誰(shuí)呢?那么正經(jīng)又暗...
    入魔小記閱讀 343評(píng)論 0 0

友情鏈接更多精彩內(nèi)容