# Your mailer is set to "none" (default on Windows), # hence we cannot send the bug report directly from R. # Please copy the bug report (after finishing it) to # your favorite email program and send it to # # r-bugs@r-project.org # ###################################################### # 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. --please do not edit the information below-- Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status major = 1 minor = 7.1 year = 2003 month = 06 day = 16 language = R Search Path: .GlobalEnv, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base =====================================I.White ICAPB, University of Edinburgh Ashworth Laboratories, West Mains Road Edinburgh EH9 3JT Fax: 0131 650 6564 Tel: 0131 650 5490 E-mail: iwhite@staffmail.ed.ac.uk
Duncan Murdoch wrote:> 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)You get it sometimes - randomly, when R doesn't crash. The bug is still present in R-devel (2003-09-05). Simple example: x <- array(1:2, dim=2) dimnames(x) <- list(1:2) crossprod(x) The point is indeed in getting dimnames for one-dimensional arrays. Uwe Ligges> 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 > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
iwhite@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]) > za 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@biostat.ku.dk) FAX: (+45) 35327907
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