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

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun Sep 7 17:18:08 MEST 2003


iwhite at staffmail.ed.ac.uk writes:

> # 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.

Confirmed. Also (and the same thing, I believe)

> z <- array(rnorm(5),5)
> crossprod(z)
         [,1]
[1,] 1.778181
> dimnames(z) <- list(letters[1:5])
> z
         a          b          c          d          e
 0.2810906  0.3457800  0.3663940 -1.1312883  0.4068751
> crossprod(z)

Program received signal SIGSEGV, Segmentation fault.
0x08094d80 in Rf_duplicate (s=0x0) at
../../../R/src/main/duplicate.c:75
75          switch (TYPEOF(s)) {

I suspect the culprit is in the logic starting at line 610 in
src/main/array.c. ("Yes, x and y have dimnames, but not along the
direction we need them"). I can't quite seem to wrap my mind around it
just now though.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list