[R] Error in FUN(newX[, i], ...) : no complete element pairs in R 2.7.0 patched

From: Bos, Roger <roger.bos_at_us.rothschild.com>
Date: Tue, 06 May 2008 08:48:41 -0400


Using R 2.6.0 patched I was able to calculate the variance of each row of a matrix without error, even if some rows had only NAs. I would just get NAs back as the variance for those rows. Now with R 2.7.0 patched I get an error "no complete element pairs" if any one row has all NAs. Can anyone tell if I can make R 2.7.0 patched behave as R 2.6.0 did so I don't have to change all my code. Or maybe suggest a simple work around. A short example is below. Thanks in advance.

dat <- data.frame(aa=c(1,2,as.numeric('NA'),4),
bb=c(2,3,as.numeric('NA'),5), cc=c(3,4,as.numeric('NA'),6),
dd=c(4,5,as.numeric('NA'),7))

apply(dat, 1, var, na.rm=TRUE)

> dat

  aa bb cc dd
1 1 2 3 4
2 2 3 4 5
3 NA NA NA NA
4 4 5 6 7
> apply(dat, 1, var, na.rm=TRUE)

Error in FUN(newX[, i], ...) : no complete element pairs
>
>


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 06 May 2008 - 12:52:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 13:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive