如何安装和管理多个版本的 R 包 [英] How to install and manage many versions of R packages

查看:29
本文介绍了如何安装和管理多个版本的 R 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 R 进行可重现计算的框架.我正在努力解决的一个问题是,某些 R 代码可能会在包的 XY-Z 版本中完美运行,但是为什么您在 3 年后尝试重现它,包已更新,某些功能已更改,并且代码不再运行.此问题还会影响例如使用包的 Sweave 文档.

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 版本和原作者使用的软件包版本.如果这是单个案例,则可以从 CRAN 档案中提取内容并安装适当的版本.但是对于我的框架来说这是不切实际的,我需要预先安装软件包版本.

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,例如2.14.安装多个版本的 R 包的实用方法是什么,以便我可以即时加载它们?我想我可以做一些事情,比如为每个包的每个版本创建单独的库目录,然后在加载它们时使用自定义 lib.loc 参数.不过这会很乱.任何提示或以前尝试做类似的事情?

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?

我的框架在 Ubuntu 服务器上运行.

My framework runs on Ubuntu server.

推荐答案

您可以安装带有版本的包(例如重命名为 foo_1.0 目录而不是 foo)和将要重新创建给定 R + 包快照的版本软链接到一个库中.显然,这些包实际上可以存在于单独的树中,因此您可以拥有 library.projectX/foo -> library.all/foo/1.0.

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.

这篇关于如何安装和管理多个版本的 R 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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