I am developing a framework for reproducible computing with R. One problem that I am struggling with is that some R code might run perfectly in version X.Y-Z of a package, but then why you try to reproduce it 3 years later, the packages have updated, some functions are changed, and the code doesn't run anymore. This problem affects also for example Sweave documents that use packages.
我正在用R开发一个可重复计算的框架,我正在努力解决的一个问题是,有些R代码可能在版本X中完美地运行。一个包的Y-Z,但是为什么3年后你要重新生成它,包已经更新了,一些函数被修改了,代码不再运行了。这个问题也会影响到使用包的Sweave文档。
The only way to confidently reproduce the results is by installing the R version and version of the packages that were used by the original author. If this was a single case, one could pull stuff from the CRAN archives and install appropriate versions. But for my framework this is impractical, and I need to have the package versions preinstalled.
唯一可以自信地再现结果的方法是安装原作者使用的包的R版本和版本。如果这是一个单独的案例,可以从CRAN归档文件中提取内容并安装适当的版本。但是对于我的框架来说,这是不切实际的,我需要预先安装包版本。
Assume for now that I restrict myself to a single version of R, e.g. 2.14. What would be a practical way to install many versions of R packages, so that I can load them on the fly? I suppose I can do something like creating separate library directories for every version of every package and then using custom lib.loc arguments while loading them. This is going to be messy though. Any tips or previous attempts to do something similar?
现在假设我把自己限制在R的单一版本,例如2.14。有什么实用的方法可以安装许多版本的R包,这样我就可以动态地加载它们?我想我可以为每个包的每个版本创建单独的库目录,然后在加载它们时使用自定义的lib.loc参数。这将会很混乱。有什么建议或尝试做类似的事情吗?
My framework runs on Ubuntu server.
我的框架在Ubuntu服务器上运行。
3 个解决方案
#1
4
You could install packages with versions (e.g. rename to foo_1.0
directory instead of foo
) and softlink the versions you want to re-create a given R + packages snapshot into one library. Obviously, the packages could actually live in a separate tree, so you could have library.projectX/foo
-> library.all/foo/1.0
.
您可以安装带有版本的包(例如重命名为foo_1.0目录,而不是foo),并将您想要重新创建的版本的版本软链接到一个库中。显然,这些包实际上可以存在于一个单独的树中,因此您可以使用库。projectX / foo - > library.all / foo / 1.0。
#2
1
The operating system gives you even more handles for complete separation, and the Debian / Ubuntu stack as a ton of those available. Two I have played with are
操作系统为完全分离提供了更多的句柄,Debian / Ubuntu栈也提供了大量可用的句柄。两个我玩过的是。
-
chroot environments: We use this to complete separate build environments from host machines. For example, all Debian uploads I produced are built in a i386 pbuilder chroot hosted on my amd64 Ubuntu server. Chroot is a very powerful Unix system call. Chroots, and particularly the pbuilder system built on top of it (for Debian package building) are meant to operate headless.
chroot环境:我们使用它来完成构建环境与主机的分离。例如,我生产的所有Debian上传都是在amd64 Ubuntu服务器上的i386 pbuilder chroot中构建的。Chroot是一个非常强大的Unix系统调用。Chroots,尤其是pbuilder系统(用于Debian软件包构建)是为了无头运行。
-
Virtual machines: This gives you full generality. My not-so-powerful box easily handles three virtual machines: Debian i386, Ubuntu i386 as well as Windoze XP. For this, I currently use KVM along with libvirt; this is Linux specific. I have also used VirtualBox and VMware in the past.
虚拟机:这提供了完整的通用性。我的不太强大的盒子可以轻松地处理三个虚拟机:Debian i386、Ubuntu i386以及Windoze XP。为此,我目前使用KVM和libvirt;这是Linux具体。我过去也使用过VirtualBox和VMware。
#3
-1
I would try to modify the DESCRIPTION file, and change the field "Package" there by adding the version number.
我将尝试修改描述文件,并通过添加版本号更改那里的“Package”字段。
For example, you download the package source a from CRAN page (http://cran.r-project.org/web/packages/pls/). Unpack the compressed file (pls_2.3-0.zip) to a directory ("pls/"). The following steps are to change the package name in DESCRIPTION ("pls/DESCRIPTION") and installation with R command 'R CMD INSTALL pls/', where 'pls/' is a path to the package source with modified DESCRIPTION file.
例如,您可以从CRAN页面(http://cran.r-project.org/web/packages/pls/)下载包源a。将压缩文件(pls_2.3-0.zip)解压到一个目录(“pls/”)。以下步骤是更改描述中的包名(“pls/DESCRIPTION”)并使用R命令'R CMD安装pls/'进行安装,其中'pls/'是使用修改描述文件的包源路径。
Playing with R library paths seems a dangerous thing to me.
在我看来,使用R库路径是一件危险的事情。
#1
4
You could install packages with versions (e.g. rename to foo_1.0
directory instead of foo
) and softlink the versions you want to re-create a given R + packages snapshot into one library. Obviously, the packages could actually live in a separate tree, so you could have library.projectX/foo
-> library.all/foo/1.0
.
您可以安装带有版本的包(例如重命名为foo_1.0目录,而不是foo),并将您想要重新创建的版本的版本软链接到一个库中。显然,这些包实际上可以存在于一个单独的树中,因此您可以使用库。projectX / foo - > library.all / foo / 1.0。
#2
1
The operating system gives you even more handles for complete separation, and the Debian / Ubuntu stack as a ton of those available. Two I have played with are
操作系统为完全分离提供了更多的句柄,Debian / Ubuntu栈也提供了大量可用的句柄。两个我玩过的是。
-
chroot environments: We use this to complete separate build environments from host machines. For example, all Debian uploads I produced are built in a i386 pbuilder chroot hosted on my amd64 Ubuntu server. Chroot is a very powerful Unix system call. Chroots, and particularly the pbuilder system built on top of it (for Debian package building) are meant to operate headless.
chroot环境:我们使用它来完成构建环境与主机的分离。例如,我生产的所有Debian上传都是在amd64 Ubuntu服务器上的i386 pbuilder chroot中构建的。Chroot是一个非常强大的Unix系统调用。Chroots,尤其是pbuilder系统(用于Debian软件包构建)是为了无头运行。
-
Virtual machines: This gives you full generality. My not-so-powerful box easily handles three virtual machines: Debian i386, Ubuntu i386 as well as Windoze XP. For this, I currently use KVM along with libvirt; this is Linux specific. I have also used VirtualBox and VMware in the past.
虚拟机:这提供了完整的通用性。我的不太强大的盒子可以轻松地处理三个虚拟机:Debian i386、Ubuntu i386以及Windoze XP。为此,我目前使用KVM和libvirt;这是Linux具体。我过去也使用过VirtualBox和VMware。
#3
-1
I would try to modify the DESCRIPTION file, and change the field "Package" there by adding the version number.
我将尝试修改描述文件,并通过添加版本号更改那里的“Package”字段。
For example, you download the package source a from CRAN page (http://cran.r-project.org/web/packages/pls/). Unpack the compressed file (pls_2.3-0.zip) to a directory ("pls/"). The following steps are to change the package name in DESCRIPTION ("pls/DESCRIPTION") and installation with R command 'R CMD INSTALL pls/', where 'pls/' is a path to the package source with modified DESCRIPTION file.
例如,您可以从CRAN页面(http://cran.r-project.org/web/packages/pls/)下载包源a。将压缩文件(pls_2.3-0.zip)解压到一个目录(“pls/”)。以下步骤是更改描述中的包名(“pls/DESCRIPTION”)并使用R命令'R CMD安装pls/'进行安装,其中'pls/'是使用修改描述文件的包源路径。
Playing with R library paths seems a dangerous thing to me.
在我看来,使用R库路径是一件危险的事情。