Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

3 Dimensional Array Names in R

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...