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

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
主站蜘蛛池模板: 武山县| 湖南省| 中西区| 措美县| 涪陵区| 涟水县| 白银市| 浙江省| 荣昌县| 黔西| 富源县| 盈江县| 黔西县| 安平县| 平泉县| 北票市| 定陶县| 寿光市| 怀柔区| 吴桥县| 二手房| 治多县| 施甸县| 长寿区| 清水河县| 金门县| 湾仔区| 南阳市| 平塘县| 巴彦县| 保亭| 盘锦市| 喀什市| 遂川县| 久治县| 徐州市| 金阳县| 宁津县| 甘洛县| 错那县| 曲麻莱县|