[R] count element in column

Andy Bunn abunn at whrc.org
Wed Jan 5 18:18:50 CET 2005


How about this?
length(res[res < 0, 1])
HTH, Andy

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Frederic renaud
> Sent: Wednesday, January 05, 2005 11:08 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] count element in column
> 
> 
> 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