I find the behavior of rbind somewhat non-intuitive when it's provided with empty vectors. For example,
rbind(numeric(0), numeric(0), numeric(0))
# [1,]
# [2,]
# [3,]
produces a 3-by-0 matrix, while I would expect the output to be a consistent numeric(0) instead. While it may be fun to debate whether you get "one nothing" or "three nothings" when you add a "nothing" to itself three times, my question is whether it's possible to suppress this behavior? Alternatively, I am looking for another function that can "rbind" matrices, while also producing an object with no rows when none of the inputs have rows.
My approach so far has been to cast numeric(0) to a matrix(0,0,0), which appears to work more consistently with rbind:
rbind(matrix(0,0,0), matrix(0,0,0), matrix(0,0,0))
# <0 x 0 matrix>
High-level picture: I have a function that accepts one or more matrices representing linear constraints, rbinds them as the first step and performs some downstream operations. The number of rows in the rbind output is taken to be the total number of input constraints. I discovered the above behavior when I was removing the last row in an input matrix and accidentally left off drop=FALSE, thus calling my function with a numeric(0) instead of a proper matrix(0,0,0) and getting the wrong total number of constraints, because nrow(rbind(numeric(0))) was returning 1.