Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 5:54 PM, steven mosher wrote: > z<-as.zooreg(as.ts(g)) >> z >          X12345 X34567 X56789 > 1989(1)      NA      3      6 > 1989(2)      NA      3      6 > 1989(3)      NA      3      6 > 1989(4)      NA      3      6 > 1989(5)      NA      3      6 > 1989(6)      NA      

Re: [R] Data frame reordering to time series

2010-08-08 Thread steven mosher
Thanks again, They worked for me as well. I did a simpler example with fewer years just to show that it worked...( shorted here for display) f <- function(x) { +dat <- x[-(1:2)] +tim <- as.yearmon(outer(x$Year, seq(0, length = ncol(dat))/12, "+")) +zoo(c(as.matrix(dat)),

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:55 AM, Gabor Grothendieck wrote: > On Sun, Aug 8, 2010 at 11:21 AM, steven mosher wrote: >> Ok, >> I'm a bit confused by what you mean by "regularly spaced" >> After I do the  do.call I do get a data structure with all the times present >> and every time has a NA or a da

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 11:21 AM, steven mosher wrote: > Ok, > I'm a bit confused by what you mean by "regularly spaced" > After I do the  do.call I do get a data structure with all the times present > and every time has a NA or a data value. > Steve > regularly spaced means that every observation

Re: [R] Data frame reordering to time series

2010-08-08 Thread steven mosher
Ok, I'm a bit confused by what you mean by "regularly spaced" After I do the do.call I do get a data structure with all the times present and every time has a NA or a data value. Steve On Sun, Aug 8, 2010 at 2:46 AM, Gabor Grothendieck wrote: > On Sun, Aug 8, 2010 at 2:01 AM, steven mosher >

Re: [R] Data frame reordering to time series

2010-08-08 Thread Gabor Grothendieck
On Sun, Aug 8, 2010 at 2:01 AM, steven mosher wrote: > In the real data the months are all complete, but the years can be missing. > So years can be missing up front, in the middle, at the end. but if a year > is present than every month has a value or NA. > To create regular R ts I had to plow th

Re: [R] Data frame reordering to time series

2010-08-07 Thread steven mosher
In the real data the months are all complete, but the years can be missing. So years can be missing up front, in the middle, at the end. but if a year is present than every month has a value or NA. To create regular R ts I had to plow through the data frame, collect a year caluculate an index to p

Re: [R] Data frame reordering to time series

2010-08-07 Thread Gabor Grothendieck
On Sat, Aug 7, 2010 at 9:18 PM, steven mosher wrote: > Very Slick. > Gabor this is a Huge speed up for me. Thanks. ha, Now I want to rewrite a > bunch of working code. > > > > Id<-c(rep(67543,4),rep(12345,3),rep(89765,5)) >  Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1)) > Value

Re: [R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Very Slick. Gabor this is a Huge speed up for me. Thanks. ha, Now I want to rewrite a bunch of working code. Id<-c(rep(67543,4),rep(12345,3),rep(89765,5)) Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1)) Values2<-c(12,NA,34,21,NA,65,23,NA,13,NA,13,14) Values<-c(12,14,34,21,5

Re: [R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Thanks Gabor, I probably should have done an example with fewer columns. i will rework the example and post it up so the next guys who has this issue can have a clear example with a solution. On Sat, Aug 7, 2010 at 5:04 PM, Gabor Grothendieck wrote: > On Sat, Aug 7, 2010 at 4:49 PM, steven mos

Re: [R] Data frame reordering to time series

2010-08-07 Thread Gabor Grothendieck
On Sat, Aug 7, 2010 at 4:49 PM, steven mosher wrote: > Given a data frame, or it could be a matrix if I choose to. > The data consists of an ID, a year, and data for all 12 months. > Missing values are a factor AND missing years. > > Id<-c(rep(67543,4),rep(12345,3),rep(89765,5)) >  Years<-c(seq(19

[R] Data frame reordering to time series

2010-08-07 Thread steven mosher
Given a data frame, or it could be a matrix if I choose to. The data consists of an ID, a year, and data for all 12 months. Missing values are a factor AND missing years. Id<-c(rep(67543,4),rep(12345,3),rep(89765,5)) Years<-c(seq(1989,1992,by =1),1991,1993,1994,seq(1991,1995,by=1)) Values2<-c(12