Re: [R] Counting non-empty levels of a factor

2009-11-08 Thread John Kane
With xx as your sample data will this work? See ?addmargins jj <- table(xx) addmargins(jj, 2) # or for both margins addmargins(jj, c(1,2)) or apply(jj, 1, sum) --- On Sun, 11/8/09, sylvain willart wrote: > From: sylvain willart > Subject: [R] Counting non-empty levels of a fa

Re: [R] Counting non-empty levels of a factor

2009-11-08 Thread sylvain willart
Thanks a lot for those solutions, Both are working great, and they do slightly different (but both very interesting) things, Moreover, I learned about the length() function ... one more to add to my personal cheat sheet King Regards 2009/11/8 David Winsemius : > > On Nov 8, 2009, at 9:11 AM, David

Re: [R] Counting non-empty levels of a factor

2009-11-08 Thread David Winsemius
On Nov 8, 2009, at 9:11 AM, David Winsemius wrote: On Nov 8, 2009, at 8:38 AM, sylvain willart wrote: Hi everyone, I'm struggling with a little problem for a while, and I'm wondering if anyone could help... I have a dataset (from retailing industry) that indicates which brands are pr

Re: [R] Counting non-empty levels of a factor

2009-11-08 Thread David Winsemius
On Nov 8, 2009, at 8:38 AM, sylvain willart wrote: Hi everyone, I'm struggling with a little problem for a while, and I'm wondering if anyone could help... I have a dataset (from retailing industry) that indicates which brands are present in a panel of 500 stores, store , brand 1 , B1 1 , B2

[R] Counting non-empty levels of a factor

2009-11-08 Thread sylvain willart
Hi everyone, I'm struggling with a little problem for a while, and I'm wondering if anyone could help... I have a dataset (from retailing industry) that indicates which brands are present in a panel of 500 stores, store , brand 1 , B1 1 , B2 1 , B3 2 , B1 2 , B3 3 , B2 3 , B3 3 , B4 I would lik