Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread Gabor Grothendieck
Very nice! On Sat, Feb 20, 2010 at 10:37 AM, Henrique Dallazuanna wrote: > Try this: > > do.call(rbind, lapply(unstack(x, V2 ~ V1), '[', 1:max(with(x, > tapply(V2, V1, length) > > On Sat, Feb 20, 2010 at 9:26 AM, Newbie19_02 wrote: >> >> Hi there, >> >> I think I'm struggling with a fairly s

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread Henrique Dallazuanna
David, Because the recycling, is needed index each element from 1 to maximum of length of the elements. ( '[' ). On Sat, Feb 20, 2010 at 1:31 PM, David Winsemius wrote: > Henrique; > > I wonder if you can comment on why that works as it does. I have tried to > pull it apart and reassemble it pie

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread Newbie19_02
Dear Henrique, THanks this works in the way that I need it to. THanks for your help. Natalie -- View this message in context: http://n4.nabble.com/Rearranging-a-data-frame-for-multiple-observations-tp1562780p1562949.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread David Winsemius
Henrique; I wonder if you can comment on why that works as it does. I have tried to pull it apart and reassemble it piece by piece, but always end up with argument recycling. > do.call(rbind, c(unstack(x, V2 ~ V1)[1], unstack(x, V2 ~ V1)[3])) [,1] [,2] [,3] [,4]

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread Henrique Dallazuanna
Try this: do.call(rbind, lapply(unstack(x, V2 ~ V1), '[', 1:max(with(x, tapply(V2, V1, length) On Sat, Feb 20, 2010 at 9:26 AM, Newbie19_02 wrote: > > Hi there, > > I think I'm struggling with a fairly simple problem but can't seem to solve > it.  I have multiple observations for one unique

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread Newbie19_02
Hi Jim, Your method works really well except that I lose the format of my dates and I'm not sure how to fix this? THanks, Natalie -- View this message in context: http://n4.nabble.com/Rearranging-a-data-frame-for-multiple-observations-tp1562780p1562836.html Sent from the R help mailing list ar

Re: [R] Rearranging a data frame for multiple observations

2010-02-20 Thread jim holtman
Is this what you want: > x <- read.table(textConnection("CAO0337134 05/09/95 + CAO0337134 27/09/05 + CAO0347741 10/10/04 + CAO0347741 12/10/04 + CAO0367128 11/07/05 + CAO0367128 12/07/05 + CAO0367128 14/07/05 + CAO0367128 19/09/97 + CAO0367128 20/09/97

[R] Rearranging a data frame for multiple observations

2010-02-20 Thread Newbie19_02
Hi there, I think I'm struggling with a fairly simple problem but can't seem to solve it. I have multiple observations for one unique identifier. Ultimately I want to end up with one line per identifier with multiple observations in rows. I'm really stuck any help would be really appreciated.