From btyner at gmail.com  Fri Feb 15 21:01:09 2008
From: btyner at gmail.com (Benjamin Tyner)
Date: Fri, 15 Feb 2008 15:01:09 -0500
Subject: [Rd] data frame with NA in names
Message-ID: <5f88b2c50802151201i26c9025bi8858a9170df688f7@mail.gmail.com>

When calling read.table() and supplying colClasses and header=FALSE,
it is possible for the resulting data frame to have NA in the names.
(The warning "not all columns named in 'colClasses' exist" is
returned)

Here is such a data frame:

x <- structure(list(a = 1:10,
                    "NA" = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)),
                    .Names = c("a", NA_character_),
                    row.names = c(NA, -10L),
                    class = "data.frame")

One undesirable property of such a data frame is that subset() has
trouble with it:

subset(x, a > 5)

Error in `[.data.frame`(x, r, vars, drop = drop) :
  undefined columns selected


Is this a bug in read.table() ?

Thanks
Ben



[Rd] data frame with NA in names
Benjamin Tyner