From: Lee Baker on
Hi,
just going through old code and trying to make it more efficient. Hoping for some good suggestions...

Say I have an array:

x =
1 0
1 1
1 1
2 0
2 1
4 0
4 0

Thus should give a contingency table of:

1 2
1 1
0 0
2 0

However, the function 'crosstab' would give the answer:

1 2
1 1
2 0

I can think of a myriad number of inefficient ways to form the full contingency table (e.g. using 2D 'for' loops, 1D 'for' loop and 'find') or a 'dirty' way of adjusting the result of 'crosstab' to give me the answer I expect (bear in mind that the outcome could be of size MxN), but does anyone know if there's a better, easy and efficient code for the above problem (preferably without using 'for' loops)?

Many thanks

Lee