[R] help for reshape function
xin wei
xinwei at stat.psu.edu
Thu Jun 17 20:22:30 CEST 2010
hi, everyone:
i have a question on the reshape function. i have the following dataset :
gene tissue patient1 patient2 patient3.............
_________________________________________________
gene1 breast 10 20 50
gene2 breast 20 40 60
gene3 breast 100 200 300
which i hope to convert to the following format:
gene patientID value gene1
-----------------------------
gene1 1 10 10
gene1 2 20 20
gene1 3 50 100
gene2 1 20 10
gene2 2 40 20
gene2 3 60 100
the column "gene" is required and column "tissue" is not needed. I use the
following syntax to perform this task:
tdata<- reshape(data, varying=names(data)[-c(1,2)],direction="long", timevar
="label",v.names="value",time=names(data)[-c(1,2)]);
however, i lose the column "gene" in the resulting tranposed dataset. I did
my best to go through the help doc for reshape. however, I am frustrated
that the examples used in the help doc is kind o hard to follow to me. Can
anyone help me modify the code to keep the column "gene" in the resulting
table?
Any constructive suggestion is welcome.
thanks
--
View this message in context: http://r.789695.n4.nabble.com/help-for-reshape-function-tp2259286p2259286.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list