attributes(x) attributes(x) <- value
The replacement form returns value.
Every data object receives two attributes ("length" and "mode") simply by being defined. "Length" specifies the number of values in the object and "mode" returns the type of object (eg. "numeric", "list", "logical", "NULL"). "Length" and "mode" are implicit attributes. However, the attributes function does not return any information on implicit attributes. Use length(x) and mode(x) to retrieve information on implicit attributes.
Other attributes may define various data types in the object ("dim") or store labels for data in the object ("dimnames" or "names"). This information will be returned by the attributes function.
For attributes known to S-PLUS, see the documentation for class, dim, dimnames, levels, names and tsp.
names(attributes(testscores)) # names of attributes of testscores attributes(testscores)attributes(foo) <- list(dim = c(2,4)) # coerces foo to a matrix