[R] counting specific elements in a column of a matrix

jim holtman jholtman at gmail.com
Sat Mar 8 21:23:14 CET 2008


?table

e.g.,   table(your.matrix[,1])

On Sat, Mar 8, 2008 at 3:15 PM, Donna Tucker <ladylilly at hotmail.com> wrote:
>
> Hello,
> I would like to know how to count the number (cardinality) of a specific element in a single row of a matrix.  At this time I have 30X3 matrix.  The first column is the treatment number for each data point.  I would like to know how many of each treatments are in this matrix.  i.e.  I want to know how many 1's are in column 1, how many 2's are in column 1, etc.  I found a couple references to the length function, but I could not make any of them work.
> Thanks,
> Donna
> _________________________________________________________________
> [[elided Hotmail spam]]
>
>        [[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list