[R] count element in column

Spencer Graves spencer.graves at pdf.com
Wed Jan 5 19:00:43 CET 2005


      Have you considered

 > sum(res[,1]<0)
[1] 2

      hope this helps.  spencer graves

Frederic renaud wrote:

>Hi,
>I 've a matrix n*1 (thus a column) and I would like to
>count the number of negative element inside.
>Can you help me?
>Thanks!
>
>eg:
> res[,1]= 1
>          -3
>          -1
>
>How obtain the number 2 (number of negative-element)?
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list