My problem is that I have weekly data from 2008, 2009 and 2010 but the number of weeks in each of these years are not the same since in we (in Denmark) code the last week in 2009 as 53. This means that I have 52 weeks in 2008 and 2010 but 53 weeks in 2009. Is there some way to make R understand this and treat the time series accordingly. Typically I want it to integrate well with ts, stl, etc. Any help or pointers on this subject would be greatly appreciated.
Packages zoo and xts handle arbitrary time indices. Pick a day of the week that will reflect the discrepancy (late enough to already be in the first week of 2009 yet early enough to be in the last week of 2009) and add it to your date. Functions zoo() or xts() will then accept the date argument after as.Date() is applied to the index with a proper format argument.
I struggled with this for a while with a problem I was working on, and in the end decided that it was better to aggregate into monthly data. It (mostly) solves the number-of-weeks problem and it helped smooth out the noise so the results were better anyhow.
An added benefit is that people have a lot of context for months, but not much for weeks of the year, so the data is more meaningful. (I.e. if I say, "April", you have ideas about the weather, holidays, etc, but if I say "week 14", who knows what to associate with that week.)
I say "mostly solves" because each month can have a different number of business days in it, and that does have to be compensated for. (Maybe something as simple as dividing the monthly total by the number of business days and work with a total per day number.)
Of course, you may need weekly data...