Apparently, indexing a list with attributes returns a list without the attributes.
> l <- list(a=1:3, b=7)
> attr(l, \'x\') <- 67
> l
$a
[1] 1
Use the sticky
package. It was designed exactly for this purpose. (Full Disclosure: I am the package author.) It's simple to use, just call sticky()
on your vector/list/etc. For example:
> l <- list(a=1:3, b=7)
> attr(l, 'x') <- 67
> l <- sticky(l)
> attr(l,'x')
> [1] 67
>
> class(l)
> [1] "sticky" "list"