1R包的安裝
1.安裝来自CRAN的R包
install.packages("openxlsx")
2.手动从网上搜索到下载.zip 或.tar.gz 文件到本地,再手动安装
# download the source file
download.file(
"https://github.com/al2na/methylKit/releases/download/v0.99.2/methylKit_0.99.2.tar.gz",destfile="methylKit_0.99.2.tar.gz")
# install the package from the source file
install.packages("methylKit_0.99.2.tar.gz",
repos=NULL,type="source")
# delete the source file
unlink("methylKit_0.99.2.tar.gz")
3.Github
devtools::install_github("tidyverse/dplyr") # 或者
remotes::install_github("tidyverse/dplyr")
4.GitHub包文件夹从网页下载下来,解压缩到当前路径(或提供完整路径),再从本地安装它
install.packages("dplyr-master", repos=NULL, type="source")
5.安装BiocManager 包
BiocManager::install("openxlsx")
2 R包的加载、更新、删除
1.加载
library(openxlsx)
2.更新
update.packages("openxlsx")
# updating CRAN packages
update.packages() # 更新所有包
# updating bioconductor packages
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install()
3.删除
remove.packages("openxlsx")
3 R包版本查询
当前已安装R包版本的查询
packageVersion("ggstatsplot")
[1] ‘0.9.1’
在网页上查找R包发布的所有版本
网址(https://cran.r-project.org/src/contrib/Archive/)
安装某一版本的R包
require(devtools)
install_version("ggplot2", version = "0.9.1", repos = "http://cran.us.r-project.org")
4 R软件的更新
更新R版本
install.packages('installr')
library(installr)
updateR()
5 在自定义位置安装包
如果您将在服务器或计算集群而不是您的个人计算机上使用 R,那么您不太可能拥有安装软件包的管理员权限。在这种情况下,您可以通过告诉 R 在哪里查找其他包来在自定义位置安装包。这是通过在您的主目录中设置一个.Renviron
文件并添加以下行来完成的:
R_LIBS=~/Rlibs
这告诉 R,您的主目录中的“Rlibs”目录将是查找包和安装包的首选位置(目录名称和位置由您决定,以上只是一个示例)。