Hallo Patrick
I found quite usefull for working with weeks package ISOweek
https://cran.r-project.org/web/packages/ISOweek/index.html
Cheers.
Petr
> -Original Message-
> From: R-help On Behalf Of Patrick
> Giraudoux
> Sent: Monday, February 22, 2021 5:24 PM
> To: Uwe Ligges ; R mailing
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
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
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")
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