[英]concurrent install of git multiple branches of an R package with `devtools::install_github()`
As the title states: is it possible to install multiple git branches of the same package side-by-side in the same R environment? 如标题所述:是否可以在同一R环境中并排安装同一软件包的多个git分支? I want to do some benchmarking and it would be easier to compare the two branches in the same session.
我想进行一些基准测试,比较同一会话中的两个分支会更容易。 I think one workaround is to change the package name in the DESCRIPTION file in the new branch, but is there a more clever way to do this with
devtools
? 我认为一种解决方法是在新分支的DESCRIPTION文件中更改软件包名称,但是是否可以使用
devtools
来实现此目的呢?
Sample code: 样例代码:
devtools::install_github("mkoohafkan/RAStestR", ref = "master")
# overwrites the prior install
devtools::install_github("mkoohafkan/RAStestR", ref = "hdf5r_transition")
In short, no. 简而言之,没有。 At least not without an extra layer.
至少并非没有额外的一层。 Read on.
继续阅读。
While git
(the protocol, as well as the client) support "branches" akin to a virtual filesystem allowing you to switch easily, R does not. 尽管
git
(协议以及客户端)都支持类似于虚拟文件系统的“分支”,但您可以轻松切换,而R则不然。
For every package you install, one and only one version can be installed. 对于您安装的每个软件包,只能安装一个版本。
But don't despair, because the file system can be used as a backend, and R can then switch by adjusting the library path . 但是不要失望,因为文件系统可以用作后端,然后R可以通过调整库路径进行切换 。 This is all in
help(Startup)
but it may help to be explicit. 这些都在
help(Startup)
但可能会有所帮助。
What you can do (and I mock this here) 你可以做什么(我在这里嘲笑)
mkdir master; cd master; installFromBranch.R master; cd ..
mkdir featureA; cd featureA; installFromBranch.R featureA; cd ..
mkdir featureB; cd featureA; installFromBranch.R featureB; cd ..
and then in R use, say, 然后在R中使用,例如
.libPaths("master"); library("mypackage")
or if you want a feature 或者如果您想要功能
.libPaths("featureA"); library("mypackage")
You can also use R_LIB_USER=featureA Rscript -e '.....someCommandHere...'
您也可以使用
R_LIB_USER=featureA Rscript -e '.....someCommandHere...'
So in short: map the branches to directories into which you install and tell R about those directories. 简而言之:将分支映射到您要安装的目录 ,并将这些目录告知R。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.