[R] Adding a time variable prior to using reshape

2010-10-06 Thread Andre Easom
Hi, I want to use reshape to convert from a skinny to a wide data format. My data doesn't have a time variable attached - I have a series of ordered observations for each subject, and it is this ordering that I am interested in (my objective is to model the most recent observation based on

Re: [R] Adding a time variable prior to using reshape

2010-10-06 Thread Henrique Dallazuanna
Try this: with(foo, ave(Value, Label, FUN = seq)) will generate the time variable xtabs(Value ~ ave(Value, Label, FUN = seq) + Label, foo) On Wed, Oct 6, 2010 at 11:07 AM, Andre Easom aea...@sportingindex.comwrote: Hi, I want to use reshape to convert from a skinny to a wide data format.

Re: [R] Adding a time variable prior to using reshape

2010-10-06 Thread peter dalgaard
On Oct 6, 2010, at 16:11 , Henrique Dallazuanna wrote: Try this: with(foo, ave(Value, Label, FUN = seq)) will generate the time variable Make that FUN=seq_along to avoid trouble with groups of size 1. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3,

Re: [R] Adding a time variable prior to using reshape

2010-10-06 Thread AndreE
Thanks, perfect! -- View this message in context: http://r.789695.n4.nabble.com/Adding-a-time-variable-prior-to-using-reshape-tp2965033p2965121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] Adding a time variable prior to using reshape

2010-10-06 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of peter dalgaard Sent: Wednesday, October 06, 2010 7:22 AM To: Henrique Dallazuanna Cc: r-help@r-project.org; Andre Easom Subject: Re: [R] Adding a time variable prior to using