Hi, Try apply function: apply(matrix,1,table)
Regards M Le 08/06/11 08:23, the_big_kowalski a écrit : > Hi, > > I have a matrix > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] > [1,] 1 3 1 1 3 1 1 2 3 2 > [2,] 1 3 1 2 1 1 1 2 2 1 > [3,] 1 2 2 3 2 1 1 1 2 1 > [4,] 3 2 1 1 1 3 1 2 1 2 > [5,] 1 1 2 2 1 1 3 1 1 2 > and want to determine how many times 1s, 2s, and 3s occur per each row. > I tried using 'table', but end up with frequencies for the whole matrix. > Thanks in advance for your help > > -- > View this message in context: > http://r.789695.n4.nabble.com/determine-frequencies-in-a-matrix-by-row-tp3581733p3581733.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- #################################### Mohamed Lajnef,IE INSERM U955 eq 15# Pôle de Psychiatrie # Hôpital CHENEVIER # 40, rue Mesly # 94010 CRETEIL Cedex FRANCE # mohamed.laj...@inserm.fr # tel : 01 49 81 32 79 # Sec : 01 49 81 32 90 # fax : 01 49 81 30 99 # #################################### [[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.