date - makedate from lubridate with year, month, and week in R -
this question has answer here:
- transform year/week date object 1 answer
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
Post a Comment