[R] Problems with crossprod

Thomas Lumley tlumley at u.washington.edu
Fri Oct 17 15:54:22 CEST 2003


On Fri, 17 Oct 2003, Liaw, Andy wrote:

> Somehow R creates `a' as a matrix with 0 rows and 5 columns.  I don't know
> how crossprod() or other linear algebra functions deals with such a
> degenerate matrix.
>
> I'd suggest R Core to add checks for strictly positive dimensions in such
> functions.

Yes. There usually are, which  is why the matrix multiplication version
works

> (Also, I find it strange that A[1,] is a vector, but A[numeric(0),] is a 0x5
> matrix...)
>

Why?  A[1,] is a 1x5 matrix, ie, a column vector, so it makes sense for it
to decay to a vector.  A[numeric(0),] is not a vector, so it stays a
matrix.

	-thomas




More information about the R-help mailing list