Re: [R] Simple Missing cases Function

From: Philipp Pagel <p.pagel_at_wzw.tum.de>
Date: Tue, 19 Apr 2011 09:44:39 +0200

On Tue, Apr 19, 2011 at 03:29:08PM +0800, Tim Elwell-Sutton wrote:
> Dear all
>
>
>
> I have written a function to perform a very simple but useful task which I
> do regularly. It is designed to show how many values are missing from each
> variable in a data.frame. In its current form it works but is slow because I
> have used several loops to achieve this simple task.

Oh - and in case you ONLY wnt the number of NAs in each column this should be pretty efficient:

lapply(foo, function(x){sum(is.na(x))})

cu

        Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
Maximus-von-Imhof-Forum 3
85354 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 19 Apr 2011 - 07:46:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Apr 2011 - 07:50:30 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.

list of date sections of archive