date - makedate from lubridate with year, month, and week in R -


this question has answer here:

i have data has columns year, month, week. how can convert date lubridate. examples in documentation use year, month, , day.

lets assume following data

year month week 2017  1     1 2017  2     35 2017  3     50 

how can use. makedate() above data?

a potential solution using base posixct.

df$complete_date <- as.date(paste(df$year, df$week, 1, sep="-"), "%y-%u-%u") 

does produce desired result?

  year month week complete_date 1 2017     1    1 2017-01-02 2 2017     2   35 2017-08-28 3 2017     3   50 2017-12-11 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -