Re: [R] count number of empty cells in a table/matrix/data.frame

From: maja zaloznik <maja.zaloznik_at_gmail.com>
Date: Thu, 03 Dec 2009 20:22:25 +0000

Thanks everyone who bothered to reply...

I'm in the middle of a working binge and my brain is clearly fried if I wasn't able to figure that one out! Time to take a break...

m.

2009/12/3 Greg Snow <Greg.Snow_at_imail.org>

> If you only want to count cells that are exactly 0.0 (not slightly
> different due to rounding errors) then try:
>
> > sum( x==0 )
>
> If you want a little wiggle room for rounding error, then you can try
> something like:
>
> > sum( -0.0000001 < x & x < 0.0000001 )
>
> Adjusting the number of 0's as you see fit.
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow_at_imail.org
> 801.408.8111
>
>
> > -----Original Message-----
> > From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-
> > project.org] On Behalf Of maiya
> > Sent: Thursday, December 03, 2009 9:29 AM
> > To: r-help_at_r-project.org
> > Subject: [R] count number of empty cells in a table/matrix/data.frame
> >
> >
> > Hi everyone!
> >
> > This is a ridiculously simple problem, I just can't seem to find the
> > solution!
> >
> > All I need is something equivalent to
> >
> > sum(is.na(x))
> >
> > but instead of counting missing values, to count empty cells (with a
> > value
> > of 0).
> >
> > A naive attempt with is.empty didn't work :)
> >
> > Thanks!
> >
> > Maja
> >
> > Oh, and if the proposed solution would be to make all the empty cells
> > into
> > missing cells, that is not an option! There are over 20,000,000 cells
> > in my
> > table, and I don't think my computer is in the mood to store two such
> > objects!
> > --
> > View this message in context: http://n4.nabble.com/count-number-of-
> > empty-cells-in-a-table-matrix-data-frame-tp947740p947740.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > 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.
>

        [[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. Received on Thu 03 Dec 2009 - 20:26:45 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 Thu 03 Dec 2009 - 21:00:29 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