I recently started using R 2.7.2, and noticed a surprising change in
the behavior of var() on NA data:
R 2.6.1 (Patched), 2007-11-26, svn.rev 43541, x86_64-unknown-linux-gnu:
> stdev(rep(NA,3), na.rm=F)
> stdev(rep(NA,3), na.rm=T)
> var(rep(NA,3), na.rm=T, use="complete.obs")
[1] NA
R 2.7.2 (Patched), 2008-09-02, svn.rev 46491, x86_64-unknown-linux-gnu:
> stdev(rep(NA,3), na.rm=F)
> stdev(rep(NA,3), na.rm=T)
Error in var(x, na.rm = na.rm) : no complete element pairs
Enter a frame number, or 0 to exit
1: stdev(rep(NA, 3), na.rm = T)
2: var(x, na.rm = na.rm)
Selection: 0
> var(rep(NA,3), na.rm=T, use="complete.obs")
Error in var(rep(NA, 3), na.rm = T, use = "complete.obs") :
no complete element pairs
Is this change intentional? Also, what is causing it? Looking, I see
no changes in var() at all, so the new behavior must be due to a
change in what this call does:
.Internal(cov(x, y, na.method, FALSE))
The R 2.7.2 cov() also has this weird line:
else if (na.method != 3L) {
Note the "L" in the "3L". A typo? The older 2.6.1 cov() just has "3"
on that line, no "L".