attributes {base} | R Documentation

## Object Attribute Lists

### Description

These functions access an object's attribute list. The first form below returns the object's attribute list. The assignment forms make the list on the right-hand side of the assignment the object's attribute list (if appropriate).

### Usage

    attributes(obj)
    attributes(obj) <- value
    mostattributes(obj) <- value

### Arguments

`obj` | an object
`value` | an appropriate attribute list, or `NULL`.

### Details

Note that some attributes (namely `class`, `comment`, `dim`, `dimnames`, `names` and `tsp`) are treated specially and have restrictions on the values which can be set.

The `mostattributes` assignment takes special care for the `dim`, `names` and `dimnames` attributes, and assigns them only when that is valid whereas an `attributes` assignment would give an error in that case.

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

### See Also

`attr`.

### Examples

    x <- cbind(a=1:3, pi=pi) # simple matrix w/ dimnames
    attributes(x)

    ## strip an object's attributes:
    attributes(x) <- NULL
    x # now just a vector of length 6

    mostattributes(x) <- list(mycomment = "really special", dim = 3:2,
       dimnames = list(LETTERS[1:3], letters[1:5]), names = paste(1:6))
    x # dim(), but not {dim}names

[Package base version 2.3.1 Index]