[R] Newbie: 'table' output in columns rather than matrix

Rolf Turner r.turner at auckland.ac.nz
Fri Sep 12 04:46:13 CEST 2008


On 12/09/2008, at 2:34 PM, Matthew Pettis wrote:

> Hi,
>
> Coming to R from SAS...
>
> I have a data.frame A with 2 long factors "x" and "y".  I want to get
> a count of the number of rows with each level of "x" and "y" jointly.
> 'table' seemed like it would work, but as I have many levels, the
> matrix output is pretty useless to me (and I don't care about zero
> values).  How can I get output that looks like:
>
> A$x A$y Freq
> ------ ----- -------
> x1    y1    8
> x1    y3   10
> ...

as.data.frame(with(A,table(x,y)))

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list