attributes
All Attributes of an Object

Description

Returns or changes all of the attributes of an object. Attributes specify the characteristics of any data object.

Usage

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

Arguments

obj any object.
value a list object.

Details

To explicitly delete all attributes of x, use attributes(x) <- NULL.
When you make an assignment, remember that some attributes accept only certain valid values. See attr for more information.
The mostattributes assignment is similar to attributes, with the following differences. For other special attributes, such as tsp, class, and others, the mostattributes assignment requires a valid value. If a valid value is not given, mostattributes fails with an error. See the examples below for more information.
Value
attributes(x) returns a list of all the attributes of x.
attributes(x) <- value returns value.
mostattributes(x) <- value returns value.
Side Effects
The attributes of x, and generally the class, are changed as a result of the assignment version of this function. The attributes of x are set to the corresponding components of value and old attributes of x are deleted.
In some cases attributes are mutually exclusive; for example, assigning names (a "names" attribute) to a matrix or array currently erases "dim" and "dimnames" attributes and changes the matrix or array to a vector.
If value has length 0, all attributes are deleted.
See Also
attr, structure, length, mode, class, dim, dimnames, levels, names, tsp.
Examples
m <- lm(y ~ x, data.frame(y=1:4, x=4:1))
attributes(m)	# attributes of a linear model
foo <- 1:8
attributes(foo) <- list(dim = c(2,4)) # coerces foo to a matrix
attributes(foo) <- NULL # removes all attributes from foo

attributes(foo) <- list(test="empty_attr", dim= c(2,4), dimnames= list(LETTERS[1:2], letters[1:4]), names = paste(1:8)) foo # with all assigned valid attributes.

mostattributes(foo) <- list(test="empty_attr", dim= c(2,4), dimnames= list(LETTERS[1:2], letters[1:4]), names = paste(1:8)) foo # with "test" , "dim" and "dimnames" but without "names" even though the names is valid

mostattributes(foo) <- list(test="empty_attr", dim= c(2,3), dimnames= list(LETTERS[1:2], letters[1:4]), names = paste(1:8)) foo # with "test" and "names" but without "dim" and "dimnames" since the given "dim" is invalid.

mostattributes(foo) <- list(test="empty_attr", dim= c(2,3), dimnames= list(LETTERS[1:2], letters[1:8]), names = paste(1:10)) foo # only with the "test" attribute. The "dim", "dimnames" and "names" are all invalid without error return.

Package base version 6.0.0-69
Package Index