R 中的 3 维数组名称 [英] 3 Dimensional Array Names in R

查看:36
本文介绍了R 中的 3 维数组名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的 3 维数组中:

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

如何设置第三维名称?

推荐答案

您可以在定义数组时设置 dimnames 参数:

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

和/或您可以像这样设置第三维的dimnames:

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

dimnames(ar)[[3]] <- c("G", "H", "I")

这篇关于R 中的 3 维数组名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆