Re: [R] dataset.date, date of an object

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Wed 05 May 2004 - 22:31:44 EST


Message-id: <loom.20040505T142110-520@post.gmane.org>

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.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:07 EST