From dmurdoch at pair.com  Sun Sep  7 12:32:01 2003
From: dmurdoch at pair.com (Duncan Murdoch)
Date: Sun Sep  7 17:56:43 2003
Subject: [Rd] bug in crossprod? (PR#4092)
In-Reply-To: <200309071501.h87F10JH001717@pubhealth.ku.dk>
References: <200309071501.h87F10JH001717@pubhealth.ku.dk>
Message-ID: <2mjmlv44juqj79hau2ort8vlhpv7shbk10@4ax.com>

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


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