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. ______________________________________________ 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.