r - time series padding with NA

后端 未结 1 1218
北恋
北恋 2020-12-19 19:24

Say, if I have a data frame as follows:

Date1 <- seq(from = as.POSIXct(\"2010-05-01 02:00\"), 
             to = as.POSIXct(\"2010-10-10 22:00\"), by = 36         


        
相关标签:
1条回答
  • 2020-12-19 19:42

    Create new data frame that contains all hours and then merge both data frames.

    df2<-data.frame(DateTime=seq(from = as.POSIXct("2010-01-01 00:00"), 
                                 to = as.POSIXct("2010-12-31 23:00"), by = "hour"))
    merge(df2,Dat,all=TRUE)
    
    0 讨论(0)
提交回复
热议问题