[R] Count number of zeros in a collumn
Murat Tasan
mmuurr at gmail.com
Mon Sep 28 01:26:37 CEST 2009
more generally, if you want to test for some minimum threshold T on
the number of zeros, try:
> if(length(which(dart[,1977] == 0)) < T) { # some code to handle the too-few-zeros-case }
On Sep 27, 4:54 pm, Marcio Resende <mresende... at yahoo.com.br> wrote:
> I have a matrix 700x2000 which is sampled in each cycle from another matrix
> 788x2000 with the numbers 0,1 and 9
>
> There is one specific collumn of this matrix, dart[,1977], that usually,
> after the samplimg procedure has only 1 and 9 (because the zero frequency in
> this collumn is low).
> However, when this happens, I want to include an IF conditional in my code.
> so basically what i wanted to do was to count the number of zeros in this
> collumn to use this information in my conditional:
>
> something like:
>
> if (the number of zeros in collumn [,1977] is zero) ... else ...
>
> I tried to find out indirectly by the rowsum but because of the sampling
> procedure the rowsum is not always the same
>
> Thank you very much
> --
> View this message in context:http://www.nabble.com/Count-number-of-zeros-in-a-collumn-tp25637516p2...
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list