Re: [R] How to group by then count?

2015-01-06 Thread Marc Schwartz
On Jan 6, 2015, at 3:29 PM, Monnand monn...@gmail.com wrote: Thank you, all! Your replies are very useful, especially Don's explanation! One complaint I have is: the function name (talbe) is really not very informative. Why not? You used the word 'table' in your original post, except as

Re: [R] How to group by then count?

2015-01-06 Thread Monnand
Thank you, all! Your replies are very useful, especially Don's explanation! One complaint I have is: the function name (talbe) is really not very informative. On Sun Jan 04 2015 at 5:03:47 PM MacQueen, Don macque...@llnl.gov wrote: This seems to me to be a case where thinking in terms of

Re: [R] How to group by then count?

2015-01-04 Thread Christian Brandstätter
Dear Monnad, one possible way would be to use as.factor() and in the summary you would get counts for every level. Like this: x = c(1, 1, 2, 1, 5, 2) summary(as.factor(x)) Cheers, Christian Hi all, I thought this was a very naive problem but I have not found any solution which is

[R] How to group by then count?

2015-01-04 Thread Monnand
Hi all, I thought this was a very naive problem but I have not found any solution which is idiomatic to R. The problem is like this: Assuming we have vector of strings: x = c(1, 1, 2, 1, 5, 2) We want to count number of appearance of each string. i.e. in vector x, string 1 appears 3 times; 2

Re: [R] How to group by then count?

2015-01-04 Thread Berend Hasselman
On 04-01-2015, at 10:02, Monnand monn...@gmail.com wrote: Hi all, I thought this was a very naive problem but I have not found any solution which is idiomatic to R. The problem is like this: Assuming we have vector of strings: x = c(1, 1, 2, 1, 5, 2) We want to count number of

Re: [R] How to group by then count?

2015-01-04 Thread MacQueen, Don
This seems to me to be a case where thinking in terms of computer programming concepts is getting in the way a bit. Approach it as a data analysis task; the S language (upon which R is based) is designed in part for data analysis so there is a function that does most of the job for you. (I