Skip to content
Prev 59460 / 63430 Next

surprised matrix (1:256, 8, 8) doesn't cause error/warning

So, does that mean that a clean result is contingent on the length of
the data being a multiple of both the number of rows and columns?

However, this rule is not straightforward.
<0 x 0 matrix>
Warning message:
In matrix(1:12, 0, 0) : data length exceeds size of matrix
[,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]   NA   NA   NA

The first example is what I would expect, but is inconsistent with the
previous examples.
(Because zero is a valid multiple of twelve).

I dislike the second example with recycling of a zero-length vector.
This *is* covered in the help file, but also seems inconsistent with
the previous examples.
(Because two and three are not valid multiples of zero).

Also, I can't think of any reason why someone would want to construct
a matrix with extra data, and then discard part of it.
And even if there was, then why not allow an arbitrarily longer length?


On Mon, Feb 1, 2021 at 10:08 PM Martin Maechler
<maechler at stat.math.ethz.ch> wrote: