R - array(): create multidimensional array

26 Aug 2017

array(data, dim) to create a multidimensional array

a <- array(1:(2*2*3), c(2,2,3))

# 1st-2nd dim filled by column
a[1,1,1] # 1
a[2,1,1] # 2
a[1,2,1] # 3
a[2,2,1] # 4

# Access like a matrix
 a[,,1]

viewed on http://www.rfunction.com

[ R  function  array  ]