Examples for 'base::attributes'


Object Attribute Lists

Aliases: attributes attributes<- mostattributes<-

Keywords: attribute

### ** Examples

x <- cbind(a = 1:3, pi = pi) # simple matrix with dimnames
attributes(x)
$dim
[1] 3 2

$dimnames
$dimnames[[1]]
NULL

$dimnames[[2]]
[1] "a"  "pi"
## strip an object's attributes:
attributes(x) <- NULL
x # now just a vector of length 6
[1] 1.000000 2.000000 3.000000 3.141593 3.141593 3.141593
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
     [,1]     [,2]
[1,]    1 3.141593
[2,]    2 3.141593
[3,]    3 3.141593
attr(,"mycomment")
[1] "really special"

[Package base version 4.2.3 Index]