[R] Age of an object?

Patrick Connolly p.connolly at hortresearch.co.nz
Wed Dec 14 21:41:04 CET 2005


On Wed, 14-Dec-2005 at 08:37AM -0400, Kjetil Brinchmann Halvorsen wrote:

|> Philippe Grosjean wrote:
|> > Martin Maechler wrote:
|> >>>>>>> "Trevor" == Trevor Hastie <hastie at stanford.edu>
|> >>>>>>>    on Tue, 13 Dec 2005 12:51:34 -0800 writes:
|> >>
|> >>     Trevor> It would be nice to have a date stamp on an object.
|> 
|> One way to do this with important objects is to use the comment function
|> (in package base)
|> 
|> comment(myobj) <- "made last sunday of 2005"

That's the beginning of the approach I used to produce a view of a
working directory that looks like this:

        Object        Mode   Rows Cols  Len    Date   
 1 lme.gca.testB   function  --    --     1 05/12/2005
 2 lme.gca.testB2  function  --    --     1 05/12/2005
 3 last.warning    list      --    --     1 01/12/2005
 4 lme.gca.testB3  function  --    --     1 01/12/2005
 5 pedigree.gold   function  --    --     1 01/12/2005
 6 kin.mat         numeric   44    44  1936 17/11/2005
 7 kin.matrix      numeric   13    13   169 17/11/2005
 8 pedigree.goldA  function  --    --     1 15/11/2005
 9 goldPed.df      dataframe 44    6      6 11/11/2005
10 plot.pedigree   function  --    --     1 11/11/2005
11 Plot.pedigree2  function  --    --     1 11/11/2005
12 every           character --    --    43 10/11/2005
13 femaleTree      character --    --  1596 10/11/2005
14 lme.gca.test2   function  --    --     1 10/11/2005
15 maleTree        character --    --  2084 10/11/2005

I keep a file that I can source one line at a time using ESS to rerun
any of the objects.  Typically, there will be data entry error repairs
to text files used to produce dataframes (no change to the script), or
I'll update a function with better thinking.  That date can be useful
information months or years later.  Some of my local functions are
nearly 10 years old and the date on them gives me an idea of how
knowledgable I might have been at the time I last updated it.  For me,
it's extremely useful and I find it cumbersome to work on a system
that doesn't have that functionality (particularly if it doesn't have
ESS either).

My approach does quite a bit more than adding a date and might be
boring to most of the list since it is somewhat involved and
convoluted, so I won't go into how it works here.

I'm sure it could be made more elegant (say, using some of the ideas
Duncan and Martin mentioned).  If anyone is keen to develop something
along these lines, I'll gladly provide ideas.

best

-- 
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand 
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~




More information about the R-help mailing list