Skip to content
Prev 61894 / 63424 Next

NROW and NCOL on NULL

?s 20:41 de 23/09/2023, Simone Giannerini escreveu:
Hello,

The way I think of this behavior that made it intuitive is to think that 
in R matrices are column-major, therefore if length(NULL) == 0 then NULL 
can be seen as a matrix with one column and zero rows, no data.

Here are other examples for which that reasoning works:


m <- matrix(integer(0L))
NCOL(m)
NROW(m)

x <- integer(0L)
NCOL(x)
NROW(x)


Not very convincing? Maybe with time...

Hope this helps,

Rui Barradas