I have a date in the follow format (year and week number):
year_week
201804
201938
201745
201402
201510
I need to get the full date in such format: 2018-02-26 (%Y-%m-%d)
.
I use the next code for this purpose:
dt[, full_date := format(ISOweek2date(sub("(\\d{4})(\\d{2})", "\\1-W\\2-1", year_week)),"%Y-%m-%d")]
but, I have the following error:
"Error: all(is.na(weekdate) | stringr::str_detect(weekdate, kPattern)) is not TRUE"
How can I get the full date in another way? Why am I having this error?
Thanks a lot for any help!
P.S. Sunday or Monday can be used as the first day of week.