可视化并跟踪您的软件包开发状态 [英] Visualizing and keeping track of your package development state

查看:130
本文介绍了可视化并跟踪您的软件包开发状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是跟踪开发状态和/或可视化所有R程序包如何相互链接(及其第三方"依赖关系)的好方法?

What is a good way of keeping track of the state of development and/or visualizing how all your R packages are linked to each other (and its "third-party" dependencies)?

我通常会尝试采用分而治之"的策略,这种策略到现在-未来5年-导致相当数量的具有明确功能范围的软件包.但是我已经到达一种状态(事情已经变得如此分散),以至于我无法将所有的依赖都束之高阁,而且我在实际项目中所需的乐高积木又在哪里":-/

I usually try to apply a "divide and conquer" strategy which by now - 5 years down the road - lead to quite some amount of packages with a clear-cut functional scope. But I've reached a state where things have (perceivably) become so scattered that I can't wrap my head around all the dependencies and "where are the lego pieces that I need for an actual project" anymore :-/

所以我想我正在寻找

  1. 所有程序包依赖项的地图表示形式
  2. 一些封装开发管理"框架/策略,占用空间最小

推荐答案

这是一种实现方法,但是当然还有其他不错的选择. 引用所有软件包的一种简单方法是使用ìnstalled.packages().如果您有多个库和解释器来分隔项目,则可以使用lib.loc指定每个项目的库位置.这将为您提供带有包装及其信息的矩阵.列之一是优先级".基本软件包将其设置为推荐"或基本".如果您开始添加"mine"或类似于您自己的东西,这是一种过滤掉自己的包装的简便方法.

This is one way to do it, but there are certainly other good alternatives. One easy way get hold of a reference to all packages is with ìnstalled.packages(). If you have several libraries and interpreters to separate projects, you can specify the library location for each project with lib.loc. This will give you matrices with packages and their information. One of the columns is "priority". Base packages set this to "recommended" or "base". If you start adding "mine" or somethiing similar to your own, that's an easy way to filter out your own packages.

通过提供库路径从每个库中获取矩阵.

Fetch the matrix from each library you have by supplying your library paths.

要查找自己的软件包,请从您通常使用的存储库中减去软件包列表,例如.对于cran mypkgs <- setdiff(installed.packages()[,1], available.packages()[,1]).然后减去基本软件包mypkgs <- setdiff(mypkgs, basePkgs). basePkgs来自miniCran,并且如上所述基于优先级进行过滤.然后,您应该拥有自己构建的软件包的列表.

To find your own packages, subtract away the list of packages from the repositories you usually use, eg. for cran mypkgs <- setdiff(installed.packages()[,1], available.packages()[,1]). Then subtract the basepackages, mypkgs <- setdiff(mypkgs, basePkgs). basePkgs is from miniCran and filters based on priority as noted above. You should then have a list of the packages you have built yourself.

然后使用miniCran中的makeDepGraph.它使用软件包名称和有关依赖项的信息.您可以为其提供install.packages,或者如果您有多个库,只需使用rbind缩小矩阵并删除重复项即可.然后用plot绘制它.

Then use makeDepGraph from miniCran. It takes the package name and information on dependencies. You can supply it with installed.packages, or if you have several libraries, just Reduce over the matrices with rbind and remove duplicates. Then plot it with plot.

如果您只想查看自己的程序包之间的依赖关系,请如上所述过滤掉其他程序包,并将其提供给makeDepGraph.

If you just want to see dependency among your own packages, filter out the other packages as above and supply that to makeDepGraph.

一个例子:我有一个用于安装各种R东西的基础安装程序,以及一个用于当前项目的带有独立解释器的库.这是"flowCore"包的示例(不是我写的).它来自Bioconductor存储库.为了争辩,我不减去生物导体包装,并假设这些是我的,以更好地解决您的问题.

An example: I have a base installation for various R stuff and another library for a current project with an isolated interpreter. Here is an example with the package "flowCore" (not written by me). It is from the Bioconductor repository. For the sake of argument I don't subtract bioconductor packages and assume these are mine to better adress your question.

require("miniCRAN")
#get package info
inst<-installed.packages()
other_inst<-installed.packages("/Users/lovetatting/Desktop/flowproj/lib/R-3.3.0/library")
cran<-available.packages()
#pick out your own packages
mypkgs<-lapply(list(inst, other_inst), function(inst){
  mine<-setdiff(
    setdiff(
      inst[,1], cran[,1]), 
    basePkgs())
})
#aggregate 
mypkgs<-Reduce(union, mypkgs)
allpkgs<-Reduce(rbind, list(inst, other_inst))

plot(makeDepGraph("flowCore", allpkgs, suggests=F))

这将导致下面的依赖关系图

This will result in the dependency graph below

如果您对跟踪依赖项有更具体的要求,则可以始终使用install.packages信息表进行操作.对于软件包开发,我本人拥有一个小型的bash函数库,主要是对R CMD ...和devtools调用的包装.而且还可以避免烦恼,例如R文件夹中文件夹层次结构的限制(我捆绑了所有东西,然后安装了它).

If you have more specific requirements on tracking of dependencies, you can always play around with the info form installed.packages. For package development I myself have a small library of bash functions, mainly wrappers around calls for R CMD ... and devtools. But also for taking care of annoyances such as the restriction of folder hierarchy in the R folder (I bundle everything, and install that).

这篇关于可视化并跟踪您的软件包开发状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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