- Modern R Programming Cookbook
- Jaynal Abedin
- 81字
- 2021-07-08 09:48:33
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
推薦閱讀
- Java范例大全
- 新編Premiere Pro CC從入門到精通
- Internet of Things with Intel Galileo
- Data Analysis with Stata
- WordPress Plugin Development Cookbook(Second Edition)
- Mastering Drupal 8 Views
- 硅谷Python工程師面試指南:數據結構、算法與系統設計
- Java語言程序設計教程
- Serverless Web Applications with React and Firebase
- QPanda量子計算編程
- ASP.NET 4.0 Web程序設計
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)
- Drupal Search Engine Optimization
- AI輔助編程Python實戰:基于GitHub Copilot和ChatGPT
- Java EE互聯網輕量級框架整合開發:SSM+Redis+Spring微服務(上下冊)