[R] Tracking when an object/function was modified
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Mar 8 15:28:32 CET 2007
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.
>
> 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.
Sorry, one addition here:
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.
Duncan Murdoch
More information about the R-help
mailing list