How to convert week and year columns to a date column with lubridate in R

Viewed 2144

I have been following along with Hadley Wickham's R for data science book. He has a lot of advice on using lubridate, but a lot of the functions assume that you have year, month, and day. How do you convert to date format when all you have is year and week using lubridate?

data.frame(
    year = c(2015, 2015, 2016, 2016, 2016, 2016, 2016),
    week = c(1, 20, 35, 49, 8, 4, 53)
  )

#year   week
#2015    1
#2015    20
#2016   35  
#2016   49  
#2016   8   
#2016   4   
#2016   53
2 Answers
Related