On Feb 20, 2014, at 12:03 PM, Michael Friendly wrote:
>
> The vector, vec, below represents a time series of the number of some events
> recorded
> for 208 two-week intervals from 2005/01/01 up to the end of 2012. I want to
> represent this together with the date information. I tried ts(), bu
Hi Michael
What about using zoo you can convert to ts if required
library(zoo)
tv <- seq(as.Date('2005/01/01'),as.Date('2013/01/01'),by=14)
zt <- zoo(vec,tv)
head(zt)
2005-01-01 2005-01-15 2005-01-29 2005-02-12 2005-02-26 2005-03-12
1 0 0 0 1
If the data are two week intervals, the frequency is 52/2 = 26
and that matches the amount of data 8*26=208:
> vec.ts <- ts(vec, start=c(2005, 1), frequency=26)
> str(vec.ts)
Time-Series [1:208] from 2005 to 2013: 1 0 0 0 1 1 1 0 2 0 ...
> print(vec.ts, calendar=TRUE)
p1 p2 p3 p4 p5 p6 p7 p8
3 matches
Mail list logo