like below fixes the issue You can see your three dimensional array as 3 bidimensional array of 4x5 elements, or 12 one dimensional array of 5 elements. That's why you have 12 rows in your output.
Casting between multi- and single-dimentional arrays
By : Joris Witteman
Date : March 29 2020, 07:55 AM
To fix this issue This came up from this answer to a previous question of mine. Is it guaranteed for the compiler to treat array the same as array? , From the C++ standard, referring to the sizeof operator:
like below fixes the issue R's arrays follow more the mathematical array object of generalized N-dimensional structure (with matrix as a special array of 2-D structure) where all elements maintain same types, similar to Python numpy array or Matlab array. Your suggested object is more akin to PHP, Perl, or Ruby multidimensional arrays (or Python lists/dictionary) which are really hash tables under the hood, and the best counterpart in R will be a named list such as below. Here you can nest lists with named objects all containing different types (character, numeric, logical, etc.). Do note: booleans in R are ALL CAPS.