【R】R语言指定包安装目录

仅针对Linux操作系统。

查看R安装目录

R #  进入R软件
.libPaths()

方法1 在 ~/.bashrc 中设置

export R_LIBS_USER=/your/path

然后采用 install.packages("ggplot2", "repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")) 即可将包安装在自己制定的 /your/path

  • 这样做的优点是别人source你的环境变量,就可以使用你安装的包

方法2 设置install.packages参数 lib

install.packages("ggplot2", "repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"), lib='/your/path/')

# repos  是指定安装镜像,上文提到的都是也可以使用国外的repos='http://cran.rstudio.com/'

清华大学bioconductor的镜像
options(BioC_mirror=”https://mirrors.tuna.tsinghua.edu.cn/bioconductor”)

你可能感兴趣的:(R,技术文档)