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

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
主站蜘蛛池模板: 浦城县| 土默特左旗| 安陆市| 谢通门县| 无极县| 元阳县| 克东县| 朝阳市| 鹿泉市| 乐昌市| 山西省| 龙里县| 赤壁市| 鹿邑县| 兴国县| 井陉县| 策勒县| 永康市| 固始县| 盐池县| 政和县| 青岛市| 平湖市| 聊城市| 青浦区| 榆中县| 双鸭山市| 永嘉县| 仁化县| 马龙县| 建阳市| 河北区| 南平市| 通渭县| 南充市| 神农架林区| 惠州市| 三门县| 海门市| 墨竹工卡县| 衡山县|