Try this: mat <- matrix(sample(1:50, 100, rep = TRUE), 10) table(mat)[which(table(mat) == 2)]
On 8/11/08, rostam shahname <[EMAIL PROTECTED]> wrote: > Hi, I wonder if there is any function which gives the number of times which > an element is repeated in the matrix. Let say there is a matrix, I would > like to find out how many times number 2 has been repeated in the matrix, or > in other words, how many elements of the matrix are equal 2. > Thanks for your help, > Rostam > > [[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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ 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.