From ripley at stats.ox.ac.uk  Mon Jul 31 13:58:56 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 31 Jul 2006 12:58:56 +0100 (BST)
Subject: [Rd] Warning when indexing data.frame with FALSE
In-Reply-To: <f8e6ff050607310442h16778689va0d70206042311e8@mail.gmail.com>
References: <f8e6ff050607310441v1cd40ae0n6fb479cbd5a763a0@mail.gmail.com>
	<f8e6ff050607310442h16778689va0d70206042311e8@mail.gmail.com>
Message-ID: <Pine.LNX.4.64.0607311253030.21136@gannet.stats.ox.ac.uk>

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.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Warning when indexing data.frame with FALSE
Prof Brian Ripley