Skip to content
Back to formatted view

Raw Message

Message-ID: <49F218AA.9020907@biostat.ku.dk>
Date: 2009-04-24T19:53:14Z
From: Peter Dalgaard
Subject: omit empty cells in crosstab?
In-Reply-To: <loom.20090424T194503-233@post.gmane.org>

Dieter Menne wrote:
> sjaffe <sjaffe <at> riskspan.com> writes:
> 
>> I have data with many factors, each taking many values. However, only
>> relatively few combinations appear in the data, ie have nonzero counts, in
>> other words the resulting table is sparse. Say we have 10 factors each with
>> 10 levels. The result of table() would exceed the memory space (on a 32bit
>> machine). Is there any way to produce a table with empty cells omitted?
>> (without first producing the whole table and then removing rows.)
> 
> It would be easier if you had a reproducible base example, but I 
> suggest to create ONE new factor of the pasted levels using unique(), 
> and  creating a table of these.

interaction(..., drop=TRUE) may be a neater way.

-- 
    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907