[R] Error in FUN(newX[, i], ...) : no complete element pairs in R 2.7.0 patched
Bos, Roger
roger.bos at us.rothschild.com
Tue May 6 14:48:41 CEST 2008
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
>
>
********************************************************************** *
This message is for the named person's use only. It may
contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by any error in
transmission. If you have received this message in error,
please immediately notify the sender by e-mail,
delete the message and all copies from your system and destroy
any hard copies. You must not, directly or indirectly, use,
disclose, distribute, print or copy any part of this message
if you are not the intended recipient.
More information about the R-help
mailing list