[R] help for reshape function

Andrie de Vries apdevries at yahoo.co.uk
Fri Jun 18 12:37:59 CEST 2010


Xin Wei

I have sympathy with your difficulties in understanding the reshape()
function.

May I recommend using the melt() and cast() functions instead, available in
the reshape package.  You can find information, help and examples here:

http://had.co.nz/reshape/

This simplifies the coding of your problem dramatically:

---

library(reshape)
df <- data.frame(gene=c("gene1", "gene2", "gene3"),
                 patient1=c(10,20,100),
                 patient2=c(20,40,200),
                 patient3=c(50,60,300))
                 
melt(df, id.vars="gene")

---

Andrie
-- 
View this message in context: http://r.789695.n4.nabble.com/help-for-reshape-function-tp2259286p2260009.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list