Re: [R] apply and table

2013-05-19 Thread arun
: R help 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, tabl

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=FAL

[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 ha