#Matrices

Create a vector from 1 to 24 with a step size of 1, then sue this to build a matrix. The byrow function determines whether the values are populated row wise (TRUE) or columnwise (FALSE)

vec1 <- 1:24
mat1 <- matrix(data = vec1, nrow = 6, ncol = 4, byrow = F)
mat1
##      [,1] [,2] [,3] [,4]
## [1,]    1    7   13   19
## [2,]    2    8   14   20
## [3,]    3    9   15   21
## [4,]    4   10   16   22
## [5,]    5   11   17   23
## [6,]    6   12   18   24
aar1 <- array(data = vec1, dim = c(3,4,2))
aar1
## , , 1
## 
##      [,1] [,2] [,3] [,4]
## [1,]    1    4    7   10
## [2,]    2    5    8   11
## [3,]    3    6    9   12
## 
## , , 2
## 
##      [,1] [,2] [,3] [,4]
## [1,]   13   16   19   22
## [2,]   14   17   20   23
## [3,]   15   18   21   24
arr2 <- aar1
dim(arr2) <- c(2,2,6)
dim(arr2)
## [1] 2 2 6
arr2
## , , 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
## 
## , , 5
## 
##      [,1] [,2]
## [1,]   17   19
## [2,]   18   20
## 
## , , 6
## 
##      [,1] [,2]
## [1,]   21   23
## [2,]   22   24