When I take one row from a two-column matrix with colnames I get a named vector > (two.columns <- matrix(1:6, 3, 2, dimnames=list(c("a", "b", "c"), c("x", "y")))) x y a 1 4 b 2 5 c 3 6 > two.columns[2,] x y 2 5 so why can't I get a named vector (of length 1) when I take one row from a one-column matrix? > (one.column <- matrix(1:3, 3, 1, dimnames=list(c("a", "b", "c"), "x"))) x a 1 b 2 c 3 > one.column[2,] [1] 2 I was expecting that it would have names "x" and that the following test would pass stopifnot(identical(names(one.column[2,]), "x")) I did not see documentation of this behavior on help("[") so I assume it is a bug.

Undocumented behaviour is not a bug, but the docs for drop() could be read as indicating that the name of the result should be "b": if the result is a vector the \code{names} are taken from the \code{dimnames} (if any). If the result is a length-one vector, the names are taken from the first dimension with a dimname. but > drop(matrix(1,1,1,dimnames=list("a","x"))) [1] 1 > drop(matrix(1,1,1,dimnames=list("a",NULL))) a 1 > drop(matrix(1,1,1,dimnames=list(NULL,"x"))) x 1 so it actually only happens if only one dimension has a dimname. However, when there is ambiguity, it seems quite reasonable to return an object with no names at all. Changing something as basic as this will break code left, right, and center, so is not likely to happen.