3 Dimensional Array Names in R

2019-01-26 05:03发布

In the 3 Dimensional array bellow :

ar <- array(someData, c(5, 5, 5));  
rownames(ar) <- ...;  #to set up row names
colnames(ar) <- ...;  #to set up col names

How can i set the third dimension names ?

标签: arrays r names
1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-26 05:28

You can either set the dimnames argument when defining the array:

ar <- array(data     = 1:27,
            dim      = c(3, 3, 3),
            dimnames = list(c("a", "b", "c"),
                            c("d", "e", "f"),
                            c("g", "h", "i")))

and/or you can set the dimnames of the third dimension like so:

dimnames(ar)[[3]] <- c("G", "H", "I")
查看更多
登录 后发表回答