merge data.frames based on year and fill in missing values

前端 未结 4 1844
-上瘾入骨i
-上瘾入骨i 2020-11-29 14:22

I have two data.frames that I want to merge together. The first is:

datess <- seq(as.Date(\'2005-01-01\'), as.Date(\'2009-12-31\'), \'days\')
sample<-          


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 14:48

    You can use match

    matched<-match(format(sample$Date,"%Y"),a$a)
    sample$y<-a$y[matched]
    sample$Z<-a$Z[matched]
    

提交回复
热议问题