On Thu, 21 Sep 2006, Thorsten Muehge wrote:
Hello R Experts,
I want to aggregate parameters by week. But our production week ends Friday
night instead of Sunday Night which is the default value in R.
The default in ISO8601, not just in R, but that is %W, not %U as used
below.
In order to solve the problem I want to substract two days from the current
data and than use the R function
test$week-format(test$dates,%U);
with a testdates format equal to 2006-09-21.
How do I substract the two days from the test$dates column in the
data.frame?
You have not told us what class test$dates is! Assuming it is Date,
test$dates-2.
*However*, to do what you ask, you need to add 1:
dates - seq(as.Date(2006-09-21), by=1, len=7)
format(dates+1, %U)
[1] 38 38 39 39 39 39 39
There is a potential problem here at year ends (there is anyway in the
ISO8601 definition). Another way is just
(unclass(dates) - 2) %/% 7
which orders weeks across years.
--
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, UKFax: +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.