Re: [R] getting ISO week

2008-12-11 Thread Gabor Grothendieck
Perhaps you mean is that the definition ought be otherwise but at least according to one standard the definition is correct: http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html On Thu, Dec 11, 2008 at 3:01 PM, Hans W. Borchers wrote: > Gabor Grothendieck gmail.com> writes: > >

Re: [R] getting ISO week

2008-12-11 Thread Hans W. Borchers
Gabor Grothendieck gmail.com> writes: > > According to the definition in ?strptime (which is not the same as the > ISO definition): > > format(x, "%W") returns > > "Week of the year as decimal number (00–53) using Monday as the first > day of week (and typically with the first Monday of the ye

Re: [R] getting ISO week

2008-12-11 Thread Gabor Grothendieck
According to the definition in ?strptime (which is not the same as the ISO definition): format(x, "%W") returns "Week of the year as decimal number (00–53) using Monday as the first day of week (and typically with the first Monday of the year as day 1 of week 1). The UK convention." The first da

Re: [R] getting ISO week

2008-12-11 Thread Hans W. Borchers
Gabor Grothendieck gmail.com> writes: > > format(d, "%U") and format(d, "%W") give week numbers using > different conventions. See ?strptime Gabor, the results of format(aDate, "W") appear to be incorrect anyway, see: format(as.Date("2008-01-01"), "%W") #-> "00" There is never a wee

Re: [R] getting ISO week

2008-12-11 Thread Gustaf Rydevik
On Thu, Dec 11, 2008 at 2:10 PM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > A slightly simpler version is > > format(Sys.Date(), "%V") > > > On Thu, 11 Dec 2008, Prof Brian Ripley wrote: > >> strftime(x, "%V") >> >> E.g. >> >> strftime(as.POSIXlt(Sys.Date()), "%V") >> >> is "50", and you might

Re: [R] getting ISO week

2008-12-11 Thread Gabor Grothendieck
format(d, "%U") and format(d, "%W") give week numbers using different conventions. See ?strptime On Thu, Dec 11, 2008 at 7:43 AM, Gustaf Rydevik <[EMAIL PROTECTED]> wrote: > Hi all, > > Is there a simple function already implemented for getting the ISO > weeks of a Date object? > I couldn't find

Re: [R] getting ISO week

2008-12-11 Thread Prof Brian Ripley
A slightly simpler version is format(Sys.Date(), "%V") On Thu, 11 Dec 2008, Prof Brian Ripley wrote: strftime(x, "%V") E.g. strftime(as.POSIXlt(Sys.Date()), "%V") is "50", and you might want as.numeric() on it. Note that this is OS-dependent, and AFAIR Windows does not have it. On Thu, 1

Re: [R] getting ISO week

2008-12-11 Thread Prof Brian Ripley
strftime(x, "%V") E.g. strftime(as.POSIXlt(Sys.Date()), "%V") is "50", and you might want as.numeric() on it. Note that this is OS-dependent, and AFAIR Windows does not have it. On Thu, 11 Dec 2008, Gustaf Rydevik wrote: Hi all, Is there a simple function already implemented for getting th

[R] getting ISO week

2008-12-11 Thread Gustaf Rydevik
Hi all, Is there a simple function already implemented for getting the ISO weeks of a Date object? I couldn't find one, and so wrote my own function to do it, but would appreciate a pointer to the "default" way. If a function is not yet implemented, could the code below be of interest to submit to