R语言基础 您所在的位置:网站首页 r的数据 R语言基础

R语言基础

2023-07-04 21:39| 来源: 网络整理| 查看: 265

R语言包的安装

参考文章

在R中大概有几种包的安装方式。

install.packages()常规包的安装

括号里面包的名称要加英文引号,在列出的CRAN镜像站点列表中选择一个进行下载,例如

install.packages(“ggplot2”)

安装包的时候可以切换安装源,如下所示:

install.packages(pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, type), method, available = NULL, destdir = NULL, dependencies = NA, type = getOption("pkgType"), configure.args = getOption("configure.args"), configure.vars = getOption("configure.vars"), clean = FALSE, Ncpus = getOption("Ncpus", 1L), verbose = getOption("verbose"), libs_only = FALSE, INSTALL_opts, quiet = FALSE, keep_outputs = FALSE, ...)

使用格式为:

install.packages("ABC",repos="http://mirror.bjtu.edu.cn/ ")

使用devtools从Github上安装包

如果是要从GitHub上安装包,需要先安装devtools,如下所示:

install.packages("devtools") install_github("genomicsclass/dagdata")

其它的包安装命令,如下所示:

install.packages("installr") # 下载并安装 installr 包 library(installr) # 装载 installr 包 install.RStudio() # 下载并安装 RStudio IDE install.Rtools() # 你需要 Rtools 来构建自己的包 install.git() #git 提供了代码的版本控制功能

如果要想把R包安装到其他位置,可以使用以下代码:

install.packages( c("xts", "zoo"), lib = "some/other/folder/to/install/to", repos = "http://www.stats.bris.ac.uk/R/")

其中lib参数就是安装的包的位置,repos就是安装源。

通过BiocLite来安装生信工具

生信很多工具是在bioconductor上,因此需要biocLite,由于R版本升级,现在安装都是BiocManager::install() 此处仍然列出,如下所示:

#source("https://bioconductor.org/biocLite.R") #options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/") # 使用相应的镜像 #biocLite(c("ALL","CLL", "pasilla", "airway")) #数据包 #biocLite(c("limma","DESeq2", "clusterProfiler")) #软件包

通过BiocManager来安装生信工具

在使用bioconductor时由于需要在线连接才能安装包,现在很多已经使用BiocManager的方式来安装,安装代码如下所示:

if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("ballgown", version = "3.8")

批量下载并且加载R包

list.of.packages


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有