R中的依赖管理 [英] Dependency management in R

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

问题描述

R是否有依赖管理工具来促进项目特定的依赖?我正在寻找类似于Java的maven,Ruby的bundler,Python的virtualenv,Node的npm等等。



我知道DESCRIPTION中的Depends子句文件,以及R_LIBS工具,但这些似乎没有一致的方式提供一些非常常见的工作流程的解决方案。



我本来喜欢能够检出项目并运行一个命令来构建和测试项目。该命令应将任何所需的软件包安装到项目特定的库中,而不影响全局R安装。例如:

  my_project / .Rlibs / * 


解决方案

作为一个差距,我写了一个新的 rbundler 包。它将项目依赖项安装到特定于项目的子目录(例如< PROJECT> /。Rbundle )中,允许用户避免使用全局库。





我们一直在Opower使用 rbundler ,并且看到一个巨大的开发人员工作流程的改进,可测试性和内部软件包的可维护性。结合我们的内部软件包存储库,我们已经能够稳定用于生产应用程序的十几个软件包的开发。



常见的工作流程:




  • 从github中查看项目

  • cd进入项目目录

  • 启动R

  • 从R控制台:


    库(rbundler) p>

    bundle('。')





所有依赖项将被安装到 ./。Rbundle 中,并且将创建一个 .Renviron 文件以下内容:

  R_LIBS_USER ='。Rbundle'

从此项目目录中运行的任何R操作都将遵循项目特定的库和包依赖关系。请注意,虽然此方法使用包DESCRIPTION来定义依赖关系,但它不需要具有实际的包结构。因此, rbundler 成为管理R项目的一般工具,无论是简单的脚本还是完整的包。


Does R have a dependency management tool to facilitate project-specific dependencies? I'm looking for something akin to Java's maven, Ruby's bundler, Python's virtualenv, Node's npm, etc.

I'm aware of the "Depends" clause in the DESCRIPTION file, as well as the R_LIBS facility, but these don't seem to work in concert to provide a solution to some very common workflows.

I'd essentially like to be able to check out a project and run a single command to build and test the project. The command should install any required packages into a project-specific library without affecting the global R installation. E.g.:

my_project/.Rlibs/*

解决方案

As a stop-gap, I've written a new rbundler package. It installs project dependencies into a project-specific subdirectory (e.g. <PROJECT>/.Rbundle), allowing the user to avoid using global libraries.

We've been using rbundler at Opower for a few months now and have seen a huge improvement in developer workflow, testability, and maintainability of internal packages. Combined with our internal package repository, we have been able to stabilize development of a dozen or so packages for use in production applications.

A common workflow:

  • Check out a project from github
  • cd into the project directory
  • Fire up R
  • From the R console:

    library(rbundler)

    bundle('.')

All dependencies will be installed into ./.Rbundle, and an .Renviron file will be created with the following contents:

R_LIBS_USER='.Rbundle'

Any R operations run from within this project directory will adhere to the project-speciic library and package dependencies. Note that, while this method uses the package DESCRIPTION to define dependencies, it needn't have an actual package structure. Thus, rbundler becomes a general tool for managing an R project, whether it be a simple script or a full-blown package.

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

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