[R] apply and table

2013-05-19 Thread Jinsong Zhao
Hi there, I have the following code: z - matrix(c(A, A, B, B, C, C, A, B, C), ncol = 3) apply(z, 2, table, c(A, B, C)) which give correct results. However, the following code: apply(z[,1,drop=FALSE], 2, table, c(A, B, C)) which does not give what I expect. I have been thought it should give

Re: [R] apply and table

2013-05-19 Thread peter dalgaard
On May 19, 2013, at 16:22 , Jinsong Zhao wrote: Hi there, I have the following code: z - matrix(c(A, A, B, B, C, C, A, B, C), ncol = 3) apply(z, 2, table, c(A, B, C)) which give correct results. However, the following code: apply(z[,1,drop=FALSE], 2, table, c(A, B, C)) which

Re: [R] apply and table

2013-05-19 Thread arun
...@yeah.net To: R help r-help@r-project.org Cc: Sent: Sunday, May 19, 2013 10:22 AM Subject: [R] apply and table Hi there, I have the following code: z - matrix(c(A, A, B, B, C, C, A, B, C), ncol = 3) apply(z, 2, table, c(A, B, C)) which give correct results. However, the following code: apply(z