[R] Detecting missing variables

David Winsemius dwinsemius at comcast.net
Mon Mar 9 05:39:48 CET 2009


If your data.frame after importing that csv file is DF, then this will  
return a list of variables with the row numbers that have missing  
values for each variables:

sapply(DF, function(x) which(is.na(x)))

But the overall tenor of you question suggests that you may need to  
back up a step and do some more basic reading of the introductory  
material that is available, including the Import/Export Manual, as  
well as re-reading the Posting Guide more carefully before your next  
question.

-- 
David Winsemius

On Mar 8, 2009, at 11:41 PM, Shreyasee wrote:

> Dear All,
>
> I have a csv file which has total 510 records and 15 variables.
> I am trying to write a code which will return me for each record which
> variable is missing.
> For e.g.
> If for record 1, variables 8 & 9 are missing, the R code should  
> return me
> that.
> In similar way I need to find the missing variables for each record.
>
> It would be a great help if anybody can explain me how should I  
> proceed.




More information about the R-help mailing list