[Rd] Bug in tapply with factors containing NAs (PR#6672)

george.leigh at dpi.qld.gov.au george.leigh at dpi.qld.gov.au
Mon Mar 15 09:29:59 MET 2004

Full_Name: George Leigh
Version: 1.8.1
OS: Windows 2000
Submission from: (NULL) (

The following example gives the correct answer when the first argument of tapply
is a numeric vector, but an incorrect answer when it is a factor.  If the
function used by tapply is "length", the type and contents of the first argument
should make no difference, provided it has the same length as the second

> x = c(NA, 1)
> y = factor(x)
> tapply(x, y, length)
> tapply(y, y, length)

More information about the R-devel mailing list