Hi,
When comparing how R2.7.0 handles missing values  I discovered that 
it differs from 2.6.2 (at least for the sd function).   In 
particular, if a column of a matrix is all NA, sd in 2.7.0 throws an 
error while in 2.6.2 it just returns NA for that column.  Is this 
intentional?

>  x <- matrix(1:50,ncol=5)
>  sd(x)
[1] 3.027650 3.027650 3.027650 3.027650 3.027650
>   x[,1] <- NA
>  sd(x,na.rm=TRUE)
Error in var(x, na.rm = na.rm) : no complete element pairs



R version 2.7.0 RC (2008-04-21 r45421)
i386-apple-darwin8.10.1

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


compare this to version 2.6.2
>  x <- matrix(1:50,ncol=5)
>  sd(x)
[1] 3.027650 3.027650 3.027650 3.027650 3.027650

>   x[,1] <- NA
>  sd(x,na.rm=TRUE)
[1]       NA 3.027650 3.027650 3.027650 3.027650

>  sessionInfo()
R version 2.6.2 (2008-02-08)
i386-apple-darwin8.10.1

locale:
en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
>

Thanks for all the great work.  Sorry not to have detected this sooner.

Bill


-- 
William Revelle         http://personality-project.org/revelle.html
Professor                       http://personality-project.org/personality.html
Department of Psychology             http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for statistics:                          http://personality-project.org/r

_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to