>>>>> "Roger" == Roger Bivand <[EMAIL PROTECTED]> >>>>> on Wed, 14 Dec 2005 15:14:47 +0100 (CET) writes:
Roger> On Wed, 14 Dec 2005, Martin Maechler wrote: >> >>>>> "Kjetil" == Kjetil Brinchmann Halvorsen <[EMAIL PROTECTED]> >> >>>>> on Wed, 14 Dec 2005 08:59:24 -0400 writes: >> Kjetil> Philippe Grosjean wrote: >> >> Martin Maechler wrote: >> >>>>>>>> "Trevor" == Trevor Hastie <[EMAIL PROTECTED]> >> >>>>>>>> on Tue, 13 Dec 2005 12:51:34 -0800 writes: >> >>> Trevor> It would be nice to have a date stamp on an object. >> Kjetil> Following up on my post of a few minutes ago, I tried to write an Kjetil> timestamp function >> Kjetil> timestamp <- function(obj, moretext){ Kjetil> comment(obj) <<- paste(Sys.time(), moretext, sep="\n") Kjetil> } >> Kjetil> but this does'nt work. >> >> >> myobj <- 1:10 >> >> timestamp(myobj, "test") Kjetil> Error in timestamp(myobj, "test") : object "obj" not found >> >> >> >> Instead, I'd **strongly** recommend to define *two* functions, >> one "constructor" and one "inspector" : >> >> "timestamp<-" <- function(obj, value) { >> stamp <- paste(Sys.time(), value) >> ## attr(obj,"timestamp") <- stamp >> comment(obj) <- stamp >> obj >> } Roger> This does treat any existing comment rather brutally, could stamp rather Roger> be: Roger> stamp <- paste(Sys.time(), comment(obj), value) Roger> probably enhanced with some field separators to let the inspector grab Roger> just its chunk? Something like DCF? Sure (and hence Duncan TL's answer). My main point was to define a "timestamp<-" function and use timestamp(......) <- .... [instead of using functions that silently modify their arguments..] Martin ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html