官术网_书友最值得收藏!

How to do it…

The simplest way to create an array is to use the array() function from R and then specify the elements and the dimension as shown in the following code snippet:

        arrayA <- array(1:16, dim=c(2,2,4))

The preceding function will produce an array of four matrices of order 2 x 2. By default, it will create the columns of the matrices and place them next to each other. The output of an array looks like this:

        > arrayA
, , 1

[,1] [,2]
[1,] 1 3
[2,] 2 4

, , 2

[,1] [,2]
[1,] 5 7
[2,] 6 8

, , 3

[,1] [,2]
[1,] 9 11
[2,] 10 12

, , 4

[,1] [,2]
[1,] 13 15
[2,] 14 16
主站蜘蛛池模板: 商城县| 潼南县| 太白县| 普定县| 德清县| 札达县| 灯塔市| 鄢陵县| 门源| 舒城县| 囊谦县| 吉林省| 东台市| 通山县| 旬邑县| 板桥市| 磐安县| 上栗县| 邳州市| 兴隆县| 清河县| 满洲里市| 新河县| 轮台县| 阿拉尔市| 蓬安县| 江西省| 海南省| 宝应县| 台北县| 丹江口市| 垣曲县| 会理县| 招远市| 神木县| 万年县| 巨鹿县| 政和县| 永寿县| 新郑市| 马公市|