[R] Tracking when an object/function was modified

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Mar 8 15:54:19 CET 2007


Duncan Murdoch wrote:
> On 3/8/2007 9:06 AM, Duncan Murdoch wrote:
>> On 3/8/2007 8:54 AM, Mona Kanaan wrote:
>>> Dear R-users,
>>>
>>> If I would like to track the date when an R-object (specifically  an R- 
>>> function) was modified, how can I achieve that? Furthermore, how can I 
>>> sort these objects based on date  modified?
>> R doesn't give you a way to do that.  Objects have no timestamps on them.

> In R 2.5.0, you'll have the option of keeping source references when you 
> use source() or parse(), and those include timestamps on files when 
> that's where the source comes from.
> 

  I did once hack the R source code so that on every assignment an 
attribute called 'lastModified' was created on the assigned object with 
the current date and time.

  The resulting compiled R didn't pass tests (I think because it then 
became impossible for two objects to be 'identical' unless they also had 
the same timestamp) and it didn't even start up properly for a similar 
reason.

  It is useful functionality to have - I envisaged a system like 'make' 
for R, where if result A depends on data B and result C, and result C 
depends on data E and F, then you can minimise the amount of computation 
needed to update A if some of B,C,D,E and F change.

  I suspect the work to put timestamps in R would be too much. Another 
possible way of doing it would require all your data to be saved in 
.RData files, for which timestamps are available (using file.info()). 
Then your 'Makefile' equivalent would save the target in a .RData file 
instead of just creating an R object.... Needs some more thought...

Barry



More information about the R-help mailing list