From jh910 at juno.com  Tue Jul 11 22:52:04 2006
From: jh910 at juno.com (J. Hosking)
Date: Tue, 11 Jul 2006 16:52:04 -0400
Subject: [Rd] Dropping unused levels of a factor that has "NA" as a level
Message-ID: <e9131k$acu$1@sea.gmane.org>

Is this a bug?

   > f1 <- factor(c("a", NA), levels = c("a", "NA") )
   > f2 <- f1[, drop = TRUE]
   > f2
   [1] a    <NA>
   Levels: a <NA>

I would have expected f2 to have only one level, "a".  It seems
to me that the code in [.factor does not follow the advice in
help("factor") on how to set factor codes to be missing when
"NA" is a level of the factor.


J. R. M. Hosking



[Rd] Dropping unused levels of a factor that has "NA" as a level
J. Hosking