The help for cbind() and rbind() says
"For cbind (rbind), vectors of zero length (including NULL) are ignored
unless the result would have zero rows (columns), for S compatibility.
(Zero-extent matrices do not occur in S3 and are not ignored in R.)"
This leads to an inconsistency.
M <- matrix(NA, 0, 0) # Make a 0x0 matrix
N <- matrix(NA, 0, 1) # Make a 0x1 matrix
dim(rbind(M, NULL, NULL)) # adds 2 rows to M
#> [1] 2 0
dim(rbind(N, NULL, NULL)) # leaves N unchanged
#> [1] 0 1
You get an extra row on the 0x0 matrix for each NULL value that is bound
to it, but the 0xn matrix is unchanged for n > 0.
Clearly from the help this is intentional, but is it desirable?
Wouldn't it make more sense for NULL to be ignored by rbind() and cbind()?
Duncan Murdoch
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel