[R] Help on reshape function

2012-03-06 Thread mails
Hello, I am trying to reshape a data.frame in wide format into long format. Although in the reshape R documentation they programmer list some examples I am struggling to bring my data.frame into long and then transform it back into wide format. The data.frame I look at is: df - data.frame(ID1

Re: [R] Help on reshape function

2012-03-06 Thread R. Michael Weylandt
library(reshape2) melt(df, id.vars = c(ID1, ID2, ID3))[, -4] # To drop an extraneous column (but you should take a look and see what it is for future reference) Michael On Tue, Mar 6, 2012 at 6:17 AM, mails mails00...@gmail.com wrote: Hello, I am trying to reshape a data.frame in wide

Re: [R] Help on reshape function

2012-03-06 Thread Liaw, Andy
] On Behalf Of R. Michael Weylandt Sent: Tuesday, March 06, 2012 8:45 AM To: mails Cc: r-help@r-project.org Subject: Re: [R] Help on reshape function library(reshape2) melt(df, id.vars = c(ID1, ID2, ID3))[, -4] # To drop an extraneous column (but you should take a look and see what

Re: [R] Help on reshape function

2012-03-06 Thread mails
Hey Michael, thanks for your help. I think the reshape2 library works much better than the normal reshape function. However, I still cannot retransform my data.frame into wide format once used melt function to transform it into long format. How do I get it back to wide format? The documentation,

Re: [R] Help on reshape function

2012-03-06 Thread R. Michael Weylandt
You'll need to use the cast() function but I can't say more unless you can provide more specifics. I believe Hadley's website has more documentation than the package: http://had.co.nz/reshape/ Michael On Tue, Mar 6, 2012 at 9:34 AM, mails mails00...@gmail.com wrote: Hey Michael, thanks for

Re: [R] Help on reshape function

2012-03-06 Thread David Winsemius
On Mar 6, 2012, at 12:45 PM, R. Michael Weylandt wrote: You'll need to use the cast() function but I can't say more unless you can provide more specifics. I believe Hadley's website has more documentation than the package: http://had.co.nz/reshape/ in reshape2 Hadley did away with cast() and

Re: [R] help for reshape function

2010-06-18 Thread Joshua Wiley
Hello, Try this, it is based off of your sample wide format data. I am not quite sure how you got the 'gene1' column in your desired output data, it looks like it is just the data from patient1, but since I was not sure, I did not include it. ## temp -

Re: [R] help for reshape function

2010-06-18 Thread Andrie de Vries
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

[R] help for reshape function

2010-06-17 Thread xin wei
hi, everyone: i have a question on the reshape function. i have the following dataset : gene tissuepatient1 patient2 patient3. _ gene1 breast 10 20 50 gene2 breast 20 40 60 gene3

Re: [R] help for reshape function

2010-06-17 Thread Henrique Dallazuanna
Try this: reshape(x, direction = 'long', varying = list(3:5), timevar = gene, v.names = value) On Thu, Jun 17, 2010 at 3:22 PM, xin wei xin...@stat.psu.edu wrote: hi, everyone: i have a question on the reshape function. i have the following dataset : gene tissuepatient1 patient2

Re: [R] help for reshape function

2010-06-17 Thread xin wei
I am afraid that your solution is not solving the problem. it seems that timevar=gene just create the followings: GENESAMPLE value id 1.11 Kidney 3.69351 1 2.11 Kidney 5.42710 2 3.11 Kidney 5.26883 3 4.11 Kidney 2.88098 4 5.11 Kidney 4.68519