[Rd] bug in crossprod? (PR#4092)

Duncan Murdoch dmurdoch at pair.com
Sun Sep 7 12:32:01 MEST 2003


On Sun, 7 Sep 2003 17:01:00 +0200 (MET DST), you wrote:

># The last line of following code produces a segmentation fault:
>
>x <- 1:10
>f <- gl(5,2)
>mns <- tapply(x,f,mean)
>crossprod(mns) #to get sum of squares of mns.
># Of course sum(mns^2) is more straightforward.

This appears to have been fixed in r-devel:  I get 

> crossprod(mns) #to get sum of squares of mns.
Error in crossprod(mns) : invalid type for dimname (must be a vector)

If you really want the answer, you should use

 crossprod(as.matrix(mns))

since crossprod is documented to require a matrix argument.  This
works in 1.7.1 too.

Duncan Murdoch



More information about the R-devel mailing list