0

The variable I want to convert is an integer in the form of YYYYWW.

So, for example 200901 represents week 1 of 2009, 201223 --> 23 of 2012 and so on.

I want to convert this variable into date format based on weeks in a year.

So in my example 01-2009 and 23-2012 or a similar format. I already tried several lubridate and ISOweek functions but never come up with a good result.

I really appreciate your help.

R. García
  • 815
  • 9
  • 20
miribini
  • 1
  • 1
  • A date always includes a day. What you have there are not dates. How you should proceed depends on the next steps you want to do. – Roland Apr 23 '18 at 08:29

1 Answers1

-3

Not sure if it works for weeks but try the solution here: https://stackoverflow.com/a/29928301/5335354

Something like:

df <- transform(df, x = as.Date(as.character(x), "%Y%U"))
Gaterde
  • 779
  • 1
  • 7
  • 25