我一直在關注Hadley Wickham的R for data science book。他對使用lubridate有很多建議,但很多功能都假設你有年,月,日。當你所有的年份和周使用lubridate時,你如何轉換爲日期格式?如何將周列和年列轉換爲Rridridate中的日期列
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
也許'有(DF1,as.Date(sprintf的( 「%d%02D 1」,一年,周), 「%Y%U%U」))' – akrun
退房這個問題:HTTPS: //stackoverflow.com/questions/9380435/how-to-parse-year-week-number-in-r –
@akrun is asdate with base or lubridate? – Alex