Comblain muriel
1997-Dec-08 11:13 UTC
R-alpha: Bug in tapply in the Windows version of September
The function tapply is not working in the Windows version of R=20 (Version 0.50 Beta (Sept 29, 1997)) In tapply <- function (x, INDEX, FUN=3DNULL, simplify=3DTRUE, ...)=20 ... The part: if (simplify && all(unlist(lapply(ans, length)) =3D=3D 1)) { ans <- unlist(ans, recursive =3D FALSE) names(ans)<-namelist[[1]] return(ans) } should be replaced by if (simplify && all(unlist(lapply(ans, length)) =3D=3D 1)) { ans <- unlist(ans, recursive =3D FALSE) if(length(INDEX) =3D=3D 1) { names(ans) <- namelist[[1]] } else { dim(ans) <- extent dimnames(ans) <- namelist } return(ans) } Muriel Comblain M=E9thodologie Quantitative Facult=E9 de Sociologie Universit=E9 de Li=E8ge=20 Bvd du Rectorat, 7 B4000 Liege, Belgique Tel: +32 4 366 30 91 E-mail: Muriel.Comblain -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Martin Maechler
1997-Dec-08 11:30 UTC
R-alpha: Bug in tapply in the Windows version of September
Dear Muriel, the current Unix version of R, 0.60, has the following definition of tapply(.). Can you check if it works for your examples? If not, please send us a complete example (i.e. with input data, we can regenerate). Thank you for your report! tapply <- function (x, INDEX, FUN=NULL, simplify=TRUE, ...) { if (is.character(FUN)) FUN <- get(FUN, mode = "function") if (!is.null(FUN) && mode(FUN) != "function") stop(paste("'", FUN, "' is not a function",sep="")) if (!is.list(INDEX)) INDEX <- list(INDEX) nI <- length(INDEX) namelist <- vector("list", nI) extent <- integer(nI) nx <- length(x) group <- rep(1, nx)#- to contain the splitting vector ngroup <- 1 for (i in seq(INDEX)) { index <- as.factor(INDEX[[i]]) if (length(index) != nx) stop("arguments must have same length") namelist[[i]] <- levels(index)#- all of them, yes ! extent[i] <- nlevels(index) group <- group + ngroup * (codes(index) - 1) ngroup <- ngroup * nlevels(index) } if (is.null(FUN)) return(group) ans <- lapply(split(x, group), FUN, ...) if (simplify && all(unlist(lapply(ans, length)) == 1)) { ansmat <- array(dim=extent, dimnames=namelist) ans <- unlist(ans, recursive = FALSE) } else { ansmat <- array(vector("list", prod(extent)), dim=extent, dimnames=namelist) } ansmat[as.numeric(names(ans))] <- ans ansmat } Martin Maechler <maechler@stat.math.ethz.ch> <>< Seminar fuer Statistik, SOL G1 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1086 http://www.stat.math.ethz.ch/~maechler/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
1997-Dec-08 12:08 UTC
R-alpha: Bug in tapply in the Windows version of September
Comblain muriel <Muriel.Comblain@ulg.ac.be> writes:> The function tapply is not working in the Windows version of R > (Version 0.50 Beta (Sept 29, 1997)) >..> The part:...> should be replaced by... Thanks. One thing though: Please, and this goes for everyone, remember to state the objective of your fixes. I think we know what this fix is about (the tapply(x,f,summary) problem, right?), but this is not stated in your letter. As Martin points out, the code has subsequently changed in the development version and we have difficulty seeing whether it solves your problem or not. -- 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Comblain muriel
1997-Dec-08 15:58 UTC
R-alpha: Bug in tapply in the Windows version of September
At 12:30 08/12/97 +0100, Martin Maechler wrote:>Dear Muriel, > >the current Unix version of R, 0.60, >has the following definition of tapply(.). > >Can you check if it works for your examples? >If not, please send us a complete example (i.e. with input data, we can >regenerate). >Thank you for your report! > >...I checked this form of the tapply function coming from the current unix version (0.60) on my examples and it worked perfectly as well as the fix I proposed. Sorry if my mail was not completely clear, I will try to do better next time and thank you for your help. =20 Muriel Comblain M=E9thodologie Quantitative Facult=E9 de Sociologie Universit=E9 de Li=E8ge=20 Bvd du Rectorat, 7 B4000 Liege, Belgique Tel: +32 4 366 30 91 E-mail: Muriel.Comblain -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._