[R] dataset.date, date of an object

Gabor Grothendieck ggrothendieck at myway.com
Wed May 5 14:31:44 CEST 2004


Jason Watts <jcwatts999 <at> yahoo.com> writes:

> 
> I'm looking for a function that returns the time at which a permanently 
stored version of a dataset (object)
> was last modified, just like dataset.date in S-Plus.  Any suggestions?

I think others have already answered this (i.e. R does not store objects in
files so you can't get the dates of those files); however, if its only
specific objects whose dates you need and you are willing to set them 
yourself you could do something like this:

# create object and set timestamp in an attribute
df <- data.frame(a=1:5,b=letters[1:5])
attr(df,"timestamp") <- Sys.time()

# ...

# update object and timestamp
df$a <- df$a+1
attr(df,"timestamp") <- Sys.time()

# ...

# show last modified time
attr(df,"timetamp")

You could get much fancier by creating a class which automatically 
appends and updates timestamps whenever an operation is performed
on its objects.   That would be even easier to use but it would
be more work to set up initially.




More information about the R-help mailing list