Re: [R] efficient is.na tabulation?

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Mon, 25 Feb 2008 09:04:30 -0500

On 2/25/2008 8:59 AM, Angelo Passalacqua wrote:
> I am aware of
>
> table(is.na(df$var))
>
> but is there an efficient way of create a table that shows the number of
> missing values in each variable of a data frame?
>
> Right now I am forced to create a new variable, varna<-is.na(df$var), for
> each variable of the data frame, bind them to a new data frame and tabulate
> it, but surely there is a simpler way?
>
> any help is greatly appreciated,
> angelo

   Are you looking for colSums(is.na(df)) or colMeans(is.na(df)) ? The is.na function can be applied to whole data frames.

> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
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 Mon 25 Feb 2008 - 14:10:40 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 Mon 25 Feb 2008 - 14:30:16 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