Re: [R] Object attributes in R

From: <>
Date: Thu 12 Oct 2006 - 23:05:10 GMT wrote:

> What I've done is to define a subclass that keeps attributes, that can
> be added to any object, shown below. The keep.attr() function is
> supposed to return just user attributes but I'm not sure if my list of
> special ones is complete.

Sorry, the following version should be better.

keep.attr <- function(x)

    a <- attributes(x)
    a[c('names','row.names','class','dim','dimnames')] <- NULL     a

keep <- function(.Data, ..., .Attr=NULL) {

    cl <- union('keep', class(.Data))'structure', c(list(.Data, class=cl, ...), .Attr)) }

'[.keep' <- function(.Data, ...)
keep(NextMethod(), .Attr=keep.attr(.Data))

'[<-.keep' <- function(.Data, ...)
keep(NextMethod(), .Attr=keep.attr(.Data)) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri Oct 13 09:13:49 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 13 Oct 2006 - 00:30:09 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.