[R] inverse table

Marc Schwartz
Wed, 15 Jun 2016 16:42:45 -0000

> On Jun 15, 2016, at 11:10 AM, Patrizio Frederic <frederic.patrizio at
gmail.com> wrote:
>
> Dear R-users,
> I've a problem that puzzle me
>
> suppose I have a two way contigency  table
>
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
>
> ddd <- (xtabs(data = ab))
> ddd <- as.matrix(ddd)
>
> the question is: how do I reverse the code, thus how do I get raw data
> (object ab) from ddd?
>
> I've tried
>
> as.data.frame.table(ddd)
>
> which is not the answer I'm looking for.
> Thanks in advance,
>
> PF


Hi,

There is a function called expand.dft(), which I posted some years ago, which is
a modification of a prior version, posted a few years before that.

The updated version is here:

  https://stat.ethz.ch/pipermail/r-help/2009-January/378521.html

If memory serves, that code has made its way into one or more packages on CRAN
but I don't recall which at the moment.

Regards,

Marc Schwartz