Try this:
reshape(x, direction = 'long', varying = list(c(2, 4), c(3, 5)), idvar
'gene')
On Thu, Feb 24, 2011 at 3:19 PM, fbarreto <fbarreto@ucsd.edu> wrote:
>
> Hi all,
>
> I have been struggling with this problem for a few days.
>
> I have a data table like this:
>
> gene rpkm1 diff1 rpkm2 diff2
> gene1 23 50 13 120
> gene2 111 220 827 1200
> gene3 75 998 71 910
>
>
> And I want to re-format it so that, for each gene, I have a 2x2 contingency
> table, such as:
>
> gene rpkm diff
> gene1 23 50
> gene1 13 120
> gene2 111 220
> gene2 827 1200
> gene3 75 998
> gene3 71 910
>
>
> I have found one post with the same problem
> (
>
http://r.789695.n4.nabble.com/R-Reshape-into-a-contingency-table-Fisher-s-test-td809122.html
> ),
> but the response was very customized for that format, and I haven't
been
> able to implement it for my need.
>
> After the table is re-formatted, I know how to do all the splitting and
> fisher tests. All I need is the re-shaping of the table, which will have
> ~9000 genes in it.
>
> Any insights are greatly appreciated!
>
> fbarreto
> --
> View this message in context:
>
http://r.789695.n4.nabble.com/reshaping-list-into-a-contingency-table-tp3323130p3323130.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]