From Mark.Bravington at csiro.au  Fri Feb 20 07:19:33 2004
From: Mark.Bravington at csiro.au (Mark.Bravington@csiro.au)
Date: Fri Feb 20 07:20:28 2004
Subject: [Rd] suggestion for update.default
Message-ID: <C4178DC99E08604EA5E2BDB989F09380090C78@extas2-hba.tas.csiro.au>

'update.default( x, ...)' checks for a component of 'x' named 'call' and gives up if there isn't one. Before giving up, how about checking for an attribute named 'call'?

I.E. something like this: 
    # Existing code:
    call <- object$call

    # Suggested insertion:
    if (is.null(call))
      call <- attr( object, 'call')

    # Existing code:
    if( is.null( call))
stop("need an object with call component or attribute") # slight mod

Why would anyone store the call as an attribute, you may ask? Well, I often find it useful to write code that returns a data.frame, which would be corrupted by adding a 'call' component-- but I still want to record how the object was generated, so I use a 'call' attribute instead. Of course it would be possible to extend the object's class to inherit from 'data.frame' and write an 'update' method for that class, but that seems like overkill.

Mark



*******************************

Mark Bravington
CSIRO (CMIS)
PO Box 1538
Castray Esplanade
Hobart
TAS 7001

phone (61) 3 6232 5118
fax (61) 3 6232 5012
Mark.Bravington@csiro.au


[Rd] suggestion for update.default
Mark.Bravington@csiro.au