Re: [Rd] Warning when indexing data.frame with FALSE

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 31 Jul 2006 - 12:43:06 GMT

Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:

> On Mon, 31 Jul 2006, hadley wickham wrote:
>
> > Sorry, a better example is:
> >
> > > data.frame(a=1)[FALSE]
> > NULL data frame with 1 rows
> > > data.frame(a=1)[NULL]
> > NULL data frame with 1 rows
> >
> > vs
> >
> > > data.frame()[FALSE]
> > Warning in is.na(nm) : is.na() applied to non-(list or vector)
> > NULL data frame with 0 rows
> > > data.frame()[NULL]
> > Warning in is.na(nm) : is.na() applied to non-(list or vector)
> > NULL data frame with 0 rows
>
> It's reasonable:
>
> > names(data.frame())
> NULL
>
> which is a problem as data frames are supposed to have names.
> So the bug is in data.frame.

To wit:

> d <- data.frame()
> names(d) <- character(0)
> d[FALSE]

NULL data frame with 0 rows
> d[NULL]

NULL data frame with 0 rows

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon Jul 31 23:00:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 31 Jul 2006 - 14:27:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.