开发者

making the subversion revision number visible in my R scripts

I'm putting this thing in my source(s)... (right, for now it's just one, plus the test scripts).

REVISION = (function(x) substring(x,开发者_如何学Python first=7, last=nchar(x)-2))("$Rev: 8727 $")

but how do "real" R programmers do?


That is a pretty good solution. A regular expression may be more robust in case you fewer or more digits: swap the beginnning $Rev : and the trailing $ for empty strings and you should have the revision left.

The only problem with the per-file properties is that they only update when this file itself is updated by subversion.

For that reason (and many others), consider making a local package. Your DESCRIPTION file will a) change often enough for the new version number and b) can simply be extended by new fields you simply add e.g.

Revision: $Rev$

You can read the content from R via read.dcf() after which you can then do your trick of stripping the dollar signs and colon, or use a regular expression.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜