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, first=7, last=nchar(x)-2))("$Rev: 8727 $")
but how do "real" R programmers do?
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, 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.