A few problems in R-0.50-a3 (which were also in R-0.49): 1) y <- c(10,11,12,13,14,NA,NA) n <- length(y) missed <- (1:n)[is.na(y)] notmissed <- (1:n)[!is.na(y)] blocks <- cut(missed,breaks=c(0,notmissed,n+1)) a <- function(v) { q <- range(v) c(q[1]-1,q[2]+1) } brackets <- tapply(missed,blocks,a) This codes gives the following in S:> brackets$"0+ thru 1": NULL $"1+ thru 2": NULL $"2+ thru 3": NULL $"3+ thru 4": NULL $"4+ thru 5": NULL $"5+ thru 8": [1] 5 8>And the following in R:> brackets <- tapply(missed,blocks,a)Error: names attribute must be same length as the vector I also had similar problems when using "lm" with data containing NA's but could not find back a precise example... 2) b <- list(2) names(b) <- "lty" a <- function(...) { par(c(...,b)) par() } a() The following is obtained in S:> win.graph() > a()$"1em": [1] 0.03150623 0.05075211 $adj: [1] 0.5 $ask: [1] F $bty: [1] "o" $cex: [1] 1
>>>>> Patrick Lindsey writes:> A few problems in R-0.50-a3 (which were also in R-0.49): > 1) > y <- c(10,11,12,13,14,NA,NA) > n <- length(y) > missed <- (1:n)[is.na(y)] > notmissed <- (1:n)[!is.na(y)] > blocks <- cut(missed,breaks=c(0,notmissed,n+1)) > a <- function(v) { > q <- range(v) > c(q[1]-1,q[2]+1) > } > brackets <- tapply(missed,blocks,a)> This codes gives the following in S: >> brackets > $"0+ thru 1": > NULL> $"1+ thru 2": > NULL> $"2+ thru 3": > NULL> $"3+ thru 4": > NULL> $"4+ thru 5": > NULL> $"5+ thru 8": > [1] 5 8>>> And the following in R:>> brackets <- tapply(missed,blocks,a) > Error: names attribute must be same length as the vector> I also had similar problems when using "lm" with data containing NA's > but could not find back a precise example...I think the patch below (which should make it into the next set of patches) fixes that. (Except for the differences in cut() ...) --- src/library/base/funs/tapply.orig Fri Feb 7 01:08:31 1997 +++ src/library/base/funs/tapply Sun Aug 10 21:57:31 1997 @@ -14,7 +14,7 @@ index <- as.factor(INDEX[[i]]) if (length(index) != nx) stop("arguments must have same length") - namelist[[i]] <- levels(index) + namelist[[i]] <- unique(levels(index)[index]) extent[[i]] <- nlevels(index) group <- group + ngroup * (codes(index) - 1) ngroup <- ngroup * nlevels(index) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>>>>> Patrick Lindsey writes: > A few problems in R-0.50-a3 (which were also in R-0.49): > 1) > y <- c(10,11,12,13,14,NA,NA) > n <- length(y) > missed <- (1:n)[is.na(y)] > notmissed <- (1:n)[!is.na(y)] > blocks <- cut(missed,breaks=c(0,notmissed,n+1)) > a <- function(v) { > q <- range(v) > c(q[1]-1,q[2]+1) > } > brackets <- tapply(missed,blocks,a)> This codes gives the following in S:> .....Kurt> I think the patch below (which should make it into the next set of Kurt> patches) fixes that. yes, it does fix the problem -- and it has been in the current source tree for about 10 days... Kurt> (Except for the differences in cut() ...) Kurt> --- src/library/base/funs/tapply.orig Fri Feb 7 01:08:31 1997 Kurt> +++ src/library/base/funs/tapply Sun Aug 10 21:57:31 1997 Kurt> @@ -14,7 +14,7 @@ Kurt> index <- as.factor(INDEX[[i]]) Kurt> if (length(index) != nx) Kurt> stop("arguments must have same length") Kurt> - namelist[[i]] <- levels(index) Kurt> + namelist[[i]] <- unique(levels(index)[index]) Kurt> extent[[i]] <- nlevels(index) Kurt> group <- group + ngroup * (codes(index) - 1) Kurt> ngroup <- ngroup * nlevels(index) Thomas, what does your function do differently ? -- Martin =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-