[R] Tracking when an object/function was modified

Duncan Murdoch murdoch at stats.uwo.ca
Thu Mar 8 15:06:32 CET 2007


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.

Adding a timestamp would be quite hard; it would need to be done at a 
very low level.  For example, you might do this:

9 AM:

f <- function() 1

10 AM:

g <- function() 2

11 AM:

f <- g

Now should the timestamp on f be 11 AM or 10 AM?  I think 11 AM makes 
more sense, but that implies modifying the way assignments are done.  If 
10 AM would be good enough, you'd only need to modify the way "function" 
works (and some other functions that modify functions, e.g. body<-, etc.)

I would say this is not worth attempting.  It's better to keep your 
function definitions in source form (e.g. in the source of a package, or 
just in a script that you'll source()), and then use tools external to R 
to track modifications.  Subversion is very good at that.

Duncan Murdoch



More information about the R-help mailing list