ges ; R mailing list project.org>; Bert Gunter
> Subject: Re: [R] strptime, date and conversion of week number into POSIX
>
> Thanks Uwe and Bert,
> I got the essential now, and can manage. Date handling stays quite a
> challenge with a variable number of weeks in a year, but
That monday does not exist. FOr the week before:
strptime(paste0("2020-52","-1"),format="%Y-%W-%u")
[1] "2020-12-28"
One week later is no longer in 2020, so there is no 53th week.
Best,
Uwe Ligges
On 22.02.2021 16:15, Patrick Giraudoux wrote:
Sorry to answer to myself, but the format was
Thanks Uwe and Bert,
I got the essential now, and can manage. Date handling stays quite a
challenge with a variable number of weeks in a year, but I can
understand why. Means eye-control (or NA detection) of strptime
conversion stays necessary...
Best,
Patrick
Le 22/02/2021 à 17:09, Uwe Ligge
I think the relevant info from ?strptime is:
"For strptime the input string need not specify the date completely: it is
assumed that unspecified seconds, minutes or hours are zero, and an
unspecified year, month or day is the current one. (However, if a month is
specified, the day of that month ha
Sorry to answer to myself, but the format was clearly incorrect in the
previous post. It should read, refering to the 1th day of the week:
strptime(paste0(mydate,"-1"),format="%Y-%W-%u")
It converts better, but with a NA on week 53
> strptime(paste0(pays$year_week,"-1"),format="%Y-%W-%u")
[1]
Dear all,
I have a trouble trying to convert dates given in character to POSIX.
The date is expressed as a year then the week number e.g. "2020-01"
(first week of 2020). I thought is can be converted as following:
strptime(mydate,format="%Y-%W")
%W refering to the week of the year as decimal
6 matches
Mail list logo