Yes, there is an easy way.  Create the regular time series you want by 
something like

x <- ts(0, start=c(2000,52), end=c(2003,9), frequency=52)

and fill in the time points you have data for by

xYear <- trunc(times(x)); xWeek <- cycle(x)
attach(mydata)
x[(xYear==year) & (xWeek==Week)] <- Count
detach()

Easy!

On Fri, 14 Feb 2003, Schnitzler, Johannes wrote:

> > I have several large data sets with counts per week. 
> > (Maximum week per year is 52. Counts from Week 53
> > are added to week 52.) 
> > 
> > A data set contains for example:
> > 
> > Year        Week    Count
> > 2000        52      2
> > 2001        1       5
> > 2001        2       7
> > 2001        5       4
> > 2001        7       2
> > ... ...     ...
> > ... ...     ...
> > 
> > Weeks with 0 counts are not listed in the data set.
> > I want to perform time series analysis (frequency 52).
> > 
> > 
> > Is there an easy way to expand the data set to:
> > 
> > Year        Week    Count
> > 2000        52      2
> > 2001        1       5
> > 2001        2       7
> > 2001        3       0
> > 2001        4       0
> > 2001        5       4
> > 2001        6       0
> > 2001        7       2
> > ... ...     ...
> > ... ...     ...
> > 
> > or is there already a function in "ts", which i have not found so far,
> > to deal with this problem?
> > 
> > 
> > Thank you very much.
> > 
> > Johannes Schnitzler
> > Germany Berlin
> > 
> >  
> >
> 
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to