如何使用其他名称安装R软件包? [英] How do I install an R package under another name?

查看:68
本文介绍了如何使用其他名称安装R软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Red Hat Enterprise Linux 6上使用R 3.4.1.我在/tools/bioinfo/app/R-3.4.1/下安装了版本3.0的软件包 asreml .lib64/R/library .

I'm using R 3.4.1 on Red Hat Enterprise Linux 6. I have version 3.0 of package asreml installed under /tools/bioinfo/app/R-3.4.1/lib64/R/library.

> library(asreml)
Loading required package: lattice
Checking for license <redacted>

> .libPaths()
[1] "/tools/bioinfo/app/R-3.4.1/lib64/R/library"

该软件包的第4版现已发布,但是我们想将第3版的结果与第4版进行比较.为此,我们希望在系统上安装 asreml4 版本4>.我已经下载了最新版本的* tar.gz文件,但如果下载了

Version 4 of that package has now come out, but we would like to compare the results of version 3 with version 4. To that end, we would like to have version4 installed on our system as asreml4. I have downloaded the *tar.gz file with the latest version, but if I do

R CMD INSTALL asreml_4.1.0.93.tar.gz

它将其安装在 asreml 文件夹中,并覆盖旧版本.那不是我想要的

it installs it in the asreml folder, overwriting the old version. That's not what I want.

我还尝试将其安装在其他位置,将文件夹重命名为 asreml4 ,然后将该文件夹复制到/tools/bioinfo/app/R-3.4.1/lib64/R/library ,然后尝试加载它,但是随后加载了错误的版本:

I've also tried to install it in another place, rename the folder to asreml4, and copy that folder to /tools/bioinfo/app/R-3.4.1/lib64/R/library and then tried to load it, but then it loads the wrong version:

> library(asreml, lib.loc="/tools/bioinfo/app/R-3.4.1/lib64/R/library/asreml4")
> packageVersion("asreml")
[1] ‘3.0.1’

那么,如何以可以通过 library(asreml4)调用它的方式将其安装在 asreml4 文件夹中?

So, how do I install it in an asreml4folder in such a way that I can call it with library(asreml4)?

推荐答案

1)编辑Description .下载源代码,将DESCRIPTION文件编辑为其他名称,然后进行构建和安装.

1) edit DESCRIPTION Download the source, edit the DESCRIPTION file to have a different name and then build and install it.

2)单独的库:将新版本替代地安装到单独的库中,然后使用其中之一来获取所需的版本:

2) separate library Alternately install the new version into a separate library and then use one of these to get the desired version:

library(asreml, lib = ...)
library(asreml)

2a).libPaths 的一种变化是使用 .libPaths(new)更改默认库路径,发出

2a) .libPaths A variation of this is to use .libPaths(new) to change the default library path, issue

library(asreml)

然后将其改回.

2b)dev_mode 完成库切换的一种简单方法是使用不带参数的 dev_mode()(来自devtools包).发出第一个 dev_mode()命令后,默认库变为〜/R-dev.那时,使用普通的 install.packages 命令安装新版本的asrmel,而无需指定 lib = ,它将被安装到〜/R-dev中.使用 library 加载它而不指定库,将导致它首先查看〜/R-dev.然后进行测试,最后准备好切换回原始库并再次生成原始asreml时,发出 dev_mode(). dev_mode()操作默认的库路径,因此您可以随时使用不带参数的 .libPaths()来检查当前的默认值.

2b) dev_mode An easy way to accomplish the library switching is to use dev_mode() without arguments (from the devtools package). After the first dev_mode() command is issued the default library becomes ~/R-dev . At that point install the new version of asrmel using an ordinary install.packages command without specifying lib= and it will be installed into ~/R-dev. Loading it using library without specifying a library will cause it to look into ~/R-dev first. Then test it out and finally when you are ready to switch back to the original library and original asreml issue dev_mode() again. dev_mode() manipulates the default library paths so you can use .libPaths() without arguments at any time to check what the current default is.

library(devtools)
dev_mode() # ~/R-dev now default library
# ...
dev_mode() # restore usual default library

这篇关于如何使用其他名称安装R软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆