3 Dimensional Array Names in R

前端 未结 2 1939
离开以前
离开以前 2020-12-15 17:29

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         


        
2条回答
  •  执笔经年
    2020-12-15 17:59

    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")
    

提交回复
热议问题