Transform year/week to date object

Viewed 19888

String contains 'YEAR WEEK' and I want to transform it with parse_date_time() to a date object but I can't make the code work:

parse_date_time(c("201510"), "YW")

I don't have to use lubridate, can be other packages, too.

2 Answers

Yes ISOweek package does this

ISOweek::ISOweek2date(isoWeek)

but for the other direction, check up the newer lubridate package as well

ISOweek::date2ISOweek(yourDate)

lubridate::isoweek(ymd(yourDate))
Related