Skip to content

Multiple tables

2 messages · Gerit Offermann, jim holtman

#
Dear list,

I have a set of 100+ variables. I would like to have one by one crosstables for each variable. I started with
table(variable1, variable2)
table(variable1, variable3)
table(variable1, variable4)
...
table(variable2, variable3)
table(variable2, variable4)
...

It seems rather tedious.

Any better ideas around?

Thanks for any help!
Gerit
#
you can use combn to create the combinations and the following will
create a list of all the results:

x1 <- x2 <- x3 <- x4 <- 1:10
comb <- combn(c('x1','x2', 'x3', 'x4'), 2)
myTab <- lapply(seq(ncol(comb)), function(x){
    table(get(comb[1, x]), get(comb[2, x]))
})
# put names of the combinations
names(myTab) <- apply(comb, 2, paste, collapse=":")
On Thu, Jan 29, 2009 at 4:19 AM, Gerit Offermann <gerit.offermann at gmx.de> wrote: