Eik Vettorazzi wrote:
But usually weeks start with a Monday. So what should happen when new
year isn't on a Monday? format(days, %W) puts the first Monday of the
year in the first week, which makes sense.
No it doesn't. Well, it does, but it will only match our planning
calendars in
R users,
I have a vector of dates
days - seq(as.Date(2007/1/1), as.Date(2008/1/31), days)
and I would like to have week numbers from 1 to 52 for each year. How
do I do that? Now I get 00-53 using
format(days, %W)
range(format(days, %W))
[1] 00 53
I have read Date and Time Classes in R (R
On Tue, Mar 18, 2008 at 7:55 AM, Lauri Nikkinen [EMAIL PROTECTED] wrote:
R users,
I have a vector of dates
days - seq(as.Date(2007/1/1), as.Date(2008/1/31), days)
and I would like to have week numbers from 1 to 52 for each year. How
do I do that? Now I get 00-53 using
format(days, %W)
Looks like you can convert to Julian date with the right origin and then
divide by 7, and take modulo 52. Something like:
julian(days, origin=days[1]-1) %/% 7 %% 52
That gets you 0-51. You just need to add one to get what you want. (I
subtract one from days[1] because it's a Monday. I'm
365/7 != 52. You have more than 52 weeks in each
year.
--- Lauri Nikkinen [EMAIL PROTECTED] wrote:
R users,
I have a vector of dates
days - seq(as.Date(2007/1/1),
as.Date(2008/1/31), days)
and I would like to have week numbers from 1 to 52
for each year. How
do I do that? Now I
Yeah, that's correct. I can accept that there is more than 52 weeks in
a year (:-)) but it's hard to accept that the first week e.g in this
example is 00 (year 2008). Should the first week be the first one, 1?
-Lauri
2008/3/18, John Kane [EMAIL PROTECTED]:
365/7 != 52. You have more than 52
--- Lauri Nikkinen [EMAIL PROTECTED] wrote:
Yeah, that's correct. I can accept that there is
more than 52 weeks in
a year (:-)) but it's hard to accept that the first
week e.g in this
example is 00 (year 2008). Should the first week be
the first one, 1?
I'd think so but I don't know much
But usually weeks start with a Monday. So what should happen when new
year isn't on a Monday? format(days, %W) puts the first Monday of the
year in the first week, which makes sense.
hth.
Lauri Nikkinen schrieb:
Yeah, that's correct. I can accept that there is more than 52 weeks in
a year
8 matches
Mail list logo