[Rd] computation with vectors of length 0 (PR#2716)
klaus.hermann at metagen.de
klaus.hermann at metagen.de
Tue Apr 1 16:24:45 MEST 2003
Full_Name: Klaus Hermann
Version: 1.5.0
OS: SUNRAY - Unix
Submission from: (NULL) (213.61.59.254)
if we produce a numeric vector of length 0 and want compute the sum over its
elements
the sum function returns 0 - this is obviously misleading. Better would be to
return
NA and give a corresponding warning.
There should be a unified strategy to handle vectors of length 0.
For example the functions sum, mean, sd handle such vectors in a different way
example:
classfreq <- c(3,3,3,3);
classfreq <- classfreq[classfreq != 3];
sum(classfreq);
mean(classfreq);
sd(classfreq);
More information about the R-devel
mailing list