Try this, It will test if a matrix x has zero length:
length(x) == 0
You can initialize a matrix by doing this:
m <- matrix(, 0, 0)
Similarly, this initializes the matrix as 1x1 containing NA:
m <- matrix()
Hope this helps!
Join Data science with R course to learn more about it.