Skip to content
Prev 140632 / 398506 Next

Tabulating Sparse Contingency Table

Dear 'Born',

There was  thread on this recently, but I cannot seem to find it.

The best suggestion (IMHO) was along these lines:

aggregate( rep(1,40), as.data.frame(diag(4)[sample(1:4,40,repl=T),]), sum )

See also

   http://thread.gmane.org/gmane.comp.lang.r.general/104798/focus=104841

and if you have a really big problem and access to unix utilities you 
might  consider something like this:

dat <- read.table( pipe('sort file.dat | uniq -c' ) )


HTH,

Chuck

p.s. the 'netiquette' of this list is to identify yourself with an 
appropriate email handle or signature block.
On Fri, 28 Mar 2008, born.to.b.wyld at gmail.com wrote:

            
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901