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.s...@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.s...@imail.org
> 801.408.8111
>
>
> > -----Original Message-----
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> > project.org] On Behalf Of maiya
> > Sent: Thursday, December 03, 2009 9:29 AM
> > To: r-help@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@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@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.

Reply via email to