Re: [R] reshaping data frame

2008-02-22 Thread ahimsa campos-arceiz
Dear Chuck, John, Vikas, and useRs, thank you very much for your great suggestions. I received three replies providing different ways to reshape my original data.frame (original question at the bottom). There are however some discrepancies in their results (most likely because I didn't explain

Re: [R] reshaping data frame

2008-02-21 Thread John Kane
Here is a very clumsy way to do it but I think it works fact1 - rep(level.1, length(mydat[,1])) fact2 - rep(level.2, length(mydat[,1])) lels - c(fact1,fact2) nams - c(indiv, case.id, covar) set1 - mydat[, c(1,2,3)] ; names(set1) - nams set2 - mydat[,c(1, 4,5)] ; names(set2) - nams newdata -

Re: [R] reshaping data frame

2008-02-21 Thread Vikas Rawal
# 2. create one new row for each case in level.1 and level.2 # the new reshaped data.frame would should look like this: # indiv factorcovar case.id # A level.1 4.6141051 # A level.1 4.6141052 # A level.2 31.0644051 # A level.2 31.0644052 #

[R] reshaping data frame

2008-02-20 Thread ahimsa campos-arceiz
Dear all, I'm having a few problems trying to reshape a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: # # data in its original shape: indiv - rep(c(A,B),c(10,10))

Re: [R] reshaping data frame

2008-02-20 Thread Chuck Cleland
On 2/20/2008 1:14 PM, ahimsa campos-arceiz wrote: Dear all, I'm having a few problems trying to reshape a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: # # data