From ripley at stats.ox.ac.uk  Tue Aug 14 15:21:13 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 14 Aug 2007 14:21:13 +0100 (BST)
Subject: [Rd] hasNA() / anyNA()?
In-Reply-To: <5f88b2c50708140448n659f6ab7gf3bc22205006112b@mail.gmail.com>
References: <5f88b2c50708140448n659f6ab7gf3bc22205006112b@mail.gmail.com>
Message-ID: <Pine.LNX.4.64.0708141416060.31152@gannet.stats.ox.ac.uk>

On Tue, 14 Aug 2007, Benjamin Tyner wrote:

> Why not
>
> hasNA <- function(x) !is.na(match(NA, x))

It hashes the whole table (here x) and so is both slower and uses more 
memory than is.na(x).

I am not clear what is meant by 'efficiency' here, or why it is needed (we 
have not been told).  But writing a C-level function to do this would have 
taken less time that this discussion has already taken ....

-- 
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] hasNA() / anyNA()?
Prof Brian Ripley