[R] Adding meta-data when creating objects. e.g: changing "<-" so to (for example) add "creation time" - how-to and pros/cons?

Michael Bedward michael.bedward at gmail.com
Thu Nov 11 11:42:03 CET 2010


As a hack you could do this...

assign("=", assign2)

Michael


On 11 November 2010 21:30, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> On Thu, Nov 11, 2010 at 9:37 AM, Tal Galili <tal.galili at gmail.com> wrote:
>
>> 4) My real intention is to somehow change the "<-" operator (not simply the
>> assign).  I am unsure as to how to do that.
>> 5) Are there any major pros/cons to the adding of such meta-data to objects?
>> (for example, excessive overhead on memory/performance)
>
>  I had a go at doing (4) a few years back. The major problem I had was
> that if you do:
>
>  y <- 1:10
>  x <- y
>
>  with a <- operator that sets a timestamp then:
>
>  identical(x,y) is FALSE.
>
> I implemented timestamping by adding an attribute to objects during
> assigment by modifying the C source, and then lots and lots of R's
> tests failed during build because identical things were no longer
> identical.
>
> Might be better to store your metadata in a separate object, .metadata
> in the global env perhaps? Then just do:
>
> .metadata[[name_of_thing]]  = list(modified=Sys.time())
>
> in your modified assign.
>
> Performance will only be a problem if your program is doing nothing
> else except fiddle with metadata, I reckon. Your program does do
> something useful, doesn't it?
>
> Barry
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list