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

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
主站蜘蛛池模板: 涟水县| 准格尔旗| 崇明县| 政和县| 易门县| 芮城县| 郴州市| 苗栗市| 泰顺县| 祁东县| 革吉县| 舟山市| 常宁市| 名山县| 西畴县| 凤山市| 西安市| 江山市| 大丰市| 繁峙县| 阜康市| 永平县| 梁平县| 息烽县| 澄迈县| 临清市| 宜都市| 钦州市| 蒙山县| 阜南县| 辉南县| 同仁县| 池州市| 贵南县| 泗水县| 抚松县| 洛南县| 友谊县| 静宁县| 故城县| 嘉兴市|