On Sun, 2 Dec 2007, Wolfgang Huber wrote: > Dear Prof. Ripley > > I noted a change in the behaviour of "cov", which is very reasonable: > > ## R version 2.7.0 Under development (unstable) (2007-11-30 r43565) > > cov(as.numeric(NA), as.numeric(NA), use="complete.obs") > Error in cov(as.numeric(NA), as.numeric(NA), use = "complete.obs") : > no complete element pairs > > whereas earlier behavior was, for example: > ## R version 2.6.0 Patched (2007-10-23 r43258) > > cov(as.numeric(NA), as.numeric(NA), use="complete.obs") > [1] NA > > > I wanted to ask whether the effect this has on "sd" is desired: > > ## R version 2.7.0 Under development (unstable) (2007-11-30 r43565) > > sd(NA, na.rm=TRUE) > Error in var(x, na.rm = na.rm) : no complete element pairs > > ## R version 2.6.0 Patched (2007-10-23 r43258) > > sd(NA, na.rm=TRUE) > [1] NA
That is a bug fix: see the NEWS entry. The previous behaviour of > sd(numeric(0)) Error in var(x, na.rm = na.rm) : 'x' is empty > sd(NA_real_, na.rm=TRUE) [1] NA was not as documented: This function computes the standard deviation of the values in 'x'. If 'na.rm' is 'TRUE' then missing values are removed before computation proceeds. so somehow an empty vector had a sd() if computed one way, and not if computed another. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel