Skip to content
Back to formatted view

Raw Message

Message-ID: <20110419074439.GB3916@maker>
Date: 2011-04-19T07:44:39Z
From: Philipp Pagel
Subject: Simple Missing cases Function
In-Reply-To: <000b01cbfe63$793bca10$6bb35e30$@hk>

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/