迁移R库 [英] Migrating R libraries

查看:87
本文介绍了迁移R库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Linux上将多个R库(*)从一个驱动器移到另一个驱动器,并想知道简单的迁移是否可行且安全,还是应该卸载并重新安装软件包.我意识到,库的位置是通过.libPaths()标识的,并且已经查阅了《 R安装和管理》手册,以了解有关迁移库的信息,但是看不到推荐的过程.

I'd like to move several R libraries (*) from one drive to another, on Linux, and would like to know whether a simple move is feasible and safe or if I should uninstall and reinstall the packages. I realize that the locations of libraries are identified via .libPaths() and have looked through the "R Installation and Administration" manual to find out about migrating libraries, but don't see a recommended process.

我认为有以下三种选择:

I perceive three options:

  1. 对所有非基本软件包运行remove.packages(),然后通过install.packages(lib = "/path/to/new/location")重新安装.
  2. 使用mv移动库(目录)并使用符号链接指向新位置(并最终删除符号链接)
  3. 按照mv命令移动目录批发并更新R_HOME/etc/Rprofile.site中的.Library.site./R-admin.html#Managing-libraries"rel =" noreferrer> R安装和管理手册
  1. Run remove.packages() for all of the non-base packages, and install anew via install.packages(lib = "/path/to/new/location").
  2. Move the libraries (directories) using mv and use symlinks to point to the new locations (and eventually remove the symlink)
  3. Use the mv command in Linux to move the directories wholesale and update .Library.site in R_HOME/etc/Rprofile.site, as suggested in the R Installation and Administration manual

选项#1变钝.选项#2应该可以,但似乎有点不合时宜.

Option #1 is blunt. Option #2 should work, but seems a bit unsound.

#3安全还是有严重问题?我发现的问题是:目录权限以及任何软件包设置存储绝对路径而不是相对路径的可能性(这似乎是不合理的和不必要的).

Is #3 safe or are there serious problems with it? The issues I've identified are: directory permissions and the possibility that any package's setup stores absolute paths rather than relative paths (which seems unsound and unnecessary).

关于绝对路径的存储,我发现rJavaR_HOME的位置存储在名为run的文件中.这不是库本身的问题,而是表示一个软件包(也是一个很好的软件包)保留绝对路径的私有副本的一个迹象.

Regarding the storage of absolute paths, I found that rJava stores the location of R_HOME in a file called run. This isn't a library problem per se, but it is one indication of a package (and a good package at that) keeping a private copy of an absolute path.

(*)有多个库和许多软件包.自然,仅库(目录)会移动,但包可能会受到影响.

(*) There are several libraries and many scores of packages. Naturally, just the libraries (directories) are moved, but packages could be affected.

更新1/澄清:只是为了澄清:我迁移库,而不更改R的版本或软件包的版本.更新R或包可以单独进行,但问题仅在于移动库是否可行.看来,如果必须更新或重新安装所有软件包以确保正确安装,则与选项#3相比,这更类似于选项#1.

UPDATE 1 / Clarification: Just to clarify: I am only migrating libraries, not changing the version of R or the versions of the packages. Updating R or the packages may be done separately, but the question is just whether or not moving the libraries is feasible. It seems that if it is necessary to update or reinstall all packages in order to be sure things are installed correctly, then that is a path more akin to option #1 than option #3.

更新2:另一篇SO帖子对如何在升级时避免此问题有一些好的想法.我没有升级R,但是Dirk Eddelbuettel建议不要在R的文件树中安装软件包.

UPDATE 2: Answers to another SO post have some good ideas on how to avoid this problem when upgrading. I'm not upgrading R, but Dirk Eddelbuettel's suggestion of not installing packages in the filetree of R is wise.

推荐答案

选项3(将旧库复制到新库)应该可以工作……但前提是只有在您随后运行时:

Option #3 (copying old library to new library) should work ... but if and only if you then run:

update.packages(checkBuilt=TRUE)

通过这种方式,需要为新版本重建的软件包将得到更新.新版本通常会添加要求(例如2.14.x中对NAMESPACE的迫切要求).

In this manner the packages that need to be rebuilt for new versions will get updated. It is often the case that new versions add requirements (such as the impending requirement in 2.14.x for NAMESPACEs).

看到这只是在躺椅上移动....如果您要移动任何基本R安装,我将放弃认可#3.它在Mac上对我有用,但是在《 R安装和管理指南》或《 R常见问题解答》中我没有看到它应该起作用的承诺.您可以按照以下顺序完成#1(在各种情况下可能是最安全的):

Seeing this is just moving around the deck chairs .... I'm going to back off from endorsing #3 if you are moving any of the base R installation. It has worked for me in a Mac, but I have not seen a promise in the R Installation and Administration Guide or the R FAQ that it should work. You can accomplish #1 (which is probably safest in various conditions) by this sequence:

# In original installation, get the non-default package list:
save.pkg.list <- installed.packages()[is.na(installed.packages()[ , "Priority"]), 1]
save(save.pkg.list, file="pkglist.Rdata")
# If you want to use remove.packages() at this point it's fine. 
# Or just delete their directories.

使用新安装的R版本,并将.Libpaths设置为您的首选项(甚至是相同的旧安装):

With a freshly installed version of R with the .Libpaths set to your preferences (or even the same old installation):

load("pkglist.Rdata")
install.packages(save.pkg.list)

如果未更改R可执行文件,则仅将软件包移至新库可能会成功(假设您还更改了.Libpaths),但是我没有Linux安装程序来对其进行测试或不知道配置操作设置的任何指针将如何受到影响.

Just moving the packages to a new library if the R executables was not changed might succeed (assuming you also change the .Libpaths) but I do not have a Linux installation to test it or know how any pointers set by configure operations would be affected.

这篇关于迁移R库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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