不规则的时间序列数据 - 我可以使其规则吗?在 r

发布于 2024-11-17 00:24:03 字数 15576 浏览 2 评论 0原文

我的数据被编程为每 5 小时获取一次信息,这意味着每天有多个数据点。问题有时是数据记录器出现故障或电池没电或其他原因,并且数据丢失或尝试失败。

我所做的所有分析都是基于这些日期。我需要根据此日期/时间戳对所有内容进行排序、过滤和选择。截至目前,我正在通过“冗长”的脚本来选择和子集我的数据。另外,我有几个数据记录器(个人),所以我也在进行批处理。例如,我想每天只使用一个数据点和子集,那么

    #Subset data by minimum time interval
    SubsetData = T
    MinInterval = 47 #minimum time interval (in hours) between consecutive locations
    ###########
    ##Setting the date and time to be recognized as date time
    loc$DateTime = as.POSIXct(strptime(loc$DT,"%m/%d/%Y %H:%M",tz="UTC"),tz="UTC")
    ### Code to subset data based on minimum time interval between locations
    if (SubsetData ==T){
             row = 0
             EndLoc = 2
             SubData1 = loc[1,]
             IDNames = levels(loc$ID)
    for (n in 1:length(IDNames)){
         IndivData = loc[loc$ID==IDNames[n],]
         row = row+1
         SubData1[row,]=IndivData[1,]
     while (EndLoc<nrow(IndivData) ){
           timediff = difftime(IndivData$DateTime[EndLoc],SubData1$DateTime[row],units = "hours")
   if (timediff>MinInterval){
       row = row+1
       SubData1=rbind(SubData1,IndivData[EndLoc,])
       EndLoc = EndLoc+1
         } else{
               EndLoc = EndLoc+1
              }
         } #end while loop
       } #end loop through individuals
     loc = SubData1
   } #end conditional to subset data
    }
   ### End Code to subset data'

,有没有一种方法可以将我的数据转换为时间序列数据,以使操作更容易?我看过有关 Zoo package a xts 的讨论 - 但这些似乎要求数据处于常规时间序列中。我什至不得不不使用某些脚本,因为它们要求数据采用 ts 格式,而我不知道如何将我的数据转换为这种良好的格式。有没有好的资源可以自学这个?我应该使用 ts 吗?

这是我的数据的示例: 结构(列表(ID = 结构(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("c_002", “c_402”),类=“因子”),长= c(-147.635233,-147.635232, -147.63632, -147.636136, -147.63628, -147.635743, -147.631785, -147.619598、-147.605088、-147.602119、-147.179737、-147.133275、 -147.106584、-147.033649、-147.016078、-147.031872、-146.940969、 -146.862538, -146.751214, -146.696238, -146.710799), 纬度 = c(67.911827, 67.911193、67.911048、67.911169、67.911625、67.911767、67.919419、 67.926327、67.925352、67.926318、70.017026、70.041163、70.057988、 70.087812、70.117134、70.147184、70.145115、70.136103、70.1276、 70.103395, 70.079301), DT = 结构(c(2L, 3L, 5L, 6L, 8L, 9L, 10L、11L、12L、14L、393L、395L、396L、398L、399L、401L、402L、 404L, 405L, 407L, 409L), .Label = c("05/01/2006 00:00", "05/01/2006 00:01", "05/01/2006 05:00", "05/01/2006 05:01", "05/01/2006 10:00", "05/01/2006 15:01", "05/01/2006 20:00", "05/01/2006 20:01", "05/02/2006 01:00", "05/02/2006 06:00", "05/02/2006 11:00", "05/02/2006 16:01", "05/02/2006 21:00", "05/02/2006 21:01", "05/03/2006 02:00", "05/03/2006 02:01", "05/03/2006 07:00", "05/03/2006 07:01", "05/03/2006 12:00", "05/03/2006 17:00", "05/03/2006 17:01", "05/03/2006 22:00", "05/03/2006 22:01", "05/04/2006 03:00", "05/04/2006 03:01", "05/04/2006 08:00", "05/04/2006 08:01", "05/04/2006 13:00", "05/04/2006 18:00", "05/04/2006 23:00", "05/04/2006 23:01", "05/05/2006 04:00", "05/05/2006 09:00", "05/05/2006 09:01", "05/05/2006 14:00", "05/05/2006 19:00", "05/06/2006 00:00", "05/06/2006 00:01", "05/06/2006 05:00", "05/06/2006 05:01", "05/06/2006 10:00", "05/06/2006 10:01", "05/06/2006 15:01", "05/06/2006 20:00", "05/06/2006 20:01", "05/07/2006 01:00", "05/07/2006 01:01", "05/07/2006 06:00", "05/07/2006 06:01", "05/07/2006 11:00", "05/07/2006 16:00", "05/07/2006 16:01", "05/07/2006 21:00", "05/08/2006 02:00", "05/08/2006 07:01", "05/08/2006 12:00", "05/08/2006 17:00", "05/08/2006 17:01", "05/08/2006 22:00", "05/08/2006 22:01", "05/09/2006 03:00", "05/09/2006 03:01", "05/09/2006 08:00", "05/09/2006 08:01", "05/09/2006 13:00", "05/09/2006 13:01", "05/09/2006 18:00", "05/09/2006 23:00", "05/09/2006 23:01", "05/10/2006 04:00", "05/10/2006 04:01", "05/10/2006 09:00", "05/10/2006 09:01", "05/10/2006 14:00", "05/10/2006 14:01", "05/10/2006 19:00", "05/10/2006 19:03", "05/11/2006 00:00", "05/11/2006 05:00", "05/11/2006 10:00", "05/11/2006 10:01", "05/11/2006 15:01", "05/11/2006 15:02", "05/11/2006 20:00", "05/11/2006 20:01", "05/12/2006 01:00", "05/12/2006 01:01", "05/12/2006 06:00", "05/12/2006 11:00", "05/12/2006 16:00", "05/12/2006 16:01", "05/12/2006 21:00", "05/12/2006 21:01", "05/13/2006 02:00", "05/13/2006 07:00", "05/13/2006 07:01", "05/13/2006 12:00", "05/13/2006 17:00", "05/13/2006 22:00", "05/13/2006 22:01", "05/14/2006 03:00", "05/14/2006 08:00", "05/14/2006 13:00", "05/14/2006 18:00", "05/14/2006 18:01", "05/14/2006 23:00", "05/15/2006 04:00", "05/15/2006 04:01", "05/15/2006 09:00", "05/15/2006 09:03", "05/15/2006 14:00", "05/15/2006 19:00", "05/16/2006 00:00", "05/16/2006 05:01", "05/16/2006 10:00", "05/16/2006 15:00", "05/16/2006 15:01", "05/16/2006 20:00", "05/17/2006 01:01", "05/17/2006 01:02", "05/17/2006 06:01", "05/17/2006 11:00", "05/17/2006 11:01", "05/17/2006 16:00", "05/17/2006 21:00", "05/18/2006 02:00", "05/18/2006 02:01", "05/18/2006 07:00", "05/18/2006 07:01", "05/18/2006 12:00", "05/18/2006 12:01", "05/18/2006 17:00", "05/18/2006 22:00", "05/18/2006 22:01", "05/19/2006 03:00", "05/19/2006 08:00", "05/19/2006 13:01", "05/19/2006 18:00", "05/19/2006 23:00", "05/19/2006 23:01", "05/20/2006 04:00", "05/20/2006 04:01", "05/20/2006 09:00", "05/20/2006 09:01", "05/20/2006 14:00", "05/20/2006 14:01", "05/20/2006 19:00", "05/21/2006 00:01", "05/21/2006 00:02", "05/21/2006 05:00", "05/21/2006 10:00", "05/21/2006 15:00", "05/21/2006 15:01", "05/21/2006 20:00", "05/22/2006 01:01", "05/22/2006 06:00", "05/22/2006 11:00", "05/22/2006 11:01", "05/22/2006 16:00", "05/22/2006 16:01", "05/22/2006 21:00", "05/22/2006 21:01", "05/23/2006 02:00", "05/23/2006 07:00", "05/23/2006 07:01", "05/23/2006 12:00", "05/23/2006 17:01", "05/23/2006 22:00", "05/24/2006 03:00", "05/24/2006 08:00", "05/24/2006 08:01", "05/24/2006 13:00", "05/24/2006 18:00", "05/24/2006 18:01", "05/24/2006 23:00", "05/24/2006 23:01", "05/25/2006 04:01", "05/25/2006 09:00", "05/25/2006 09:02", "05/25/2006 14:01", "05/25/2006 19:01", "05/26/2006 00:01", "05/26/2006 05:00", "05/26/2006 10:00", "05/26/2006 15:00", "05/26/2006 20:00", "05/27/2006 01:00", "05/27/2006 01:01", "05/27/2006 06:00", "05/27/2006 11:00", "05/27/2006 16:00", "05/27/2006 16:01", "05/27/2006 21:01", "05/28/2006 02:00", "05/28/2006 02:01", "05/28/2006 07:00", "05/28/2006 07:01", "05/28/2006 12:01", "05/28/2006 17:00", "05/28/2006 22:00", "05/29/2006 03:00", "05/29/2006 03:01", "05/29/2006 08:00", "05/29/2006 13:00", "05/29/2006 13:01", "05/29/2006 18:00", "05/29/2006 23:01", "05/30/2006 04:00", "05/30/2006 09:00", "05/30/2006 14:00", "05/30/2006 14:01", "05/30/2006 19:00", "05/30/2006 19:01", "05/31/2006 00:00", "05/31/2006 00:01", "05/31/2006 05:01", "05/31/2006 10:00", "05/31/2006 10:01", "05/31/2006 15:00", "05/31/2006 15:01", "05/31/2006 20:00", "06/01/2006 01:00", "06/01/2006 01:01", "06/01/2006 06:00", "06/01/2006 06:01", "06/01/2006 11:00", "06/01/2006 11:01", "06/01/2006 16:00", "06/01/2006 21:01", "06/02/2006 02:01", "06/02/2006 07:00", "06/02/2006 12:00", "06/02/2006 12:01", "06/02/2006 17:00", "06/02/2006 17:02", "06/02/2006 22:01", "06/03/2006 03:00", "06/03/2006 03:01", "06/03/2006 08:00", "06/03/2006 08:01", "06/03/2006 13:00", "06/03/2006 13:01", "06/03/2006 18:00", "06/03/2006 23:00", "06/04/2006 04:00", "06/04/2006 04:01", "06/04/2006 09:00", "06/04/2006 09:01", "06/04/2006 14:00", "06/04/2006 19:00", "06/05/2006 00:00", "06/05/2006 05:01", "06/05/2006 10:00", "06/05/2006 15:00", "06/05/2006 20:00", "06/06/2006 01:00", "06/06/2006 01:01", "06/06/2006 06:01", "06/06/2006 11:00", "06/06/2006 11:01", "06/06/2006 16:00", "06/06/2006 21:00", "06/06/2006 21:01", "06/07/2006 02:01", "06/07/2006 07:00", "06/07/2006 07:01", "06/07/2006 12:00", "06/07/2006 12:01", "06/07/2006 17:00", "06/07/2006 17:01", "06/07/2006 22:00", "06/07/2006 22:01", "06/08/2006 03:00", "06/08/2006 08:00", "06/08/2006 08:01", "06/08/2006 13:00", "06/08/2006 13:01", "06/08/2006 18:00", "06/08/2006 23:00", "06/09/2006 04:00", "06/09/2006 09:00", "06/09/2006 14:00", "06/09/2006 19:00", "06/10/2006 00:01", "06/10/2006 00:02", "06/10/2006 05:00", "06/10/2006 10:00", "06/10/2006 15:00", "06/10/2006 20:01", "06/11/2006 01:00", "06/11/2006 01:01", "06/11/2006 06:00", "06/11/2006 11:00", "06/11/2006 16:00", "06/11/2006 16:01", "06/11/2006 21:00", "06/12/2006 02:01", "06/12/2006 02:02", "06/12/2006 07:00", "06/12/2006 07:01", "06/12/2006 12:00", "06/12/2006 17:00", "06/12/2006 17:01", "06/12/2006 22:00", "06/12/2006 22:01", "06/13/2006 03:00", "06/13/2006 03:01", "06/13/2006 08:00", "06/13/2006 08:01", "06/13/2006 13:00", "06/13/2006 13:03", "06/13/2006 18:00", "06/13/2006 18:01", "06/13/2006 23:00", "06/13/2006 23:01", "06/14/2006 04:00", "06/14/2006 04:01", "06/14/2006 09:00", "06/14/2006 09:01", "06/14/2006 14:00", "06/14/2006 14:01", "06/14/2006 19:00", "06/15/2006 00:00", "06/15/2006 05:01", "06/15/2006 10:00", "06/15/2006 15:00", "06/15/2006 15:01", "06/15/2006 20:00", "06/15/2006 20:01", "06/16/2006 01:01", "06/16/2006 06:00", "06/16/2006 06:01", "06/16/2006 11:00", "06/16/2006 11:01", "06/16/2006 16:00", "06/16/2006 16:01", "06/16/2006 21:00", "06/16/2006 21:01", "06/17/2006 02:00", "06/17/2006 07:00", "06/17/2006 07:01", "06/17/2006 12:00", "06/17/2006 12:01", "06/17/2006 17:00", "06/17/2006 22:00", "06/18/2006 03:00", "06/18/2006 03:01", "06/18/2006 08:01", "06/18/2006 13:00", "06/18/2006 13:01", "06/18/2006 18:01", "06/18/2006 23:00", "06/19/2006 04:00", "06/19/2006 04:01", "06/19/2006 09:00", "06/19/2006 09:01", "06/19/2006 14:01", "06/19/2006 19:01", "06/20/2006 00:00", "06/20/2006 05:00", "06/20/2006 05:01", "06/20/2006 10:01", "06/20/2006 15:00", "06/20/2006 15:01", "06/20/2006 20:00", "06/21/2006 01:00", "06/21/2006 01:01", "06/21/2006 06:00", "06/21/2006 06:01", "06/21/2006 11:01", "06/21/2006 16:00", "06/21/2006 16:01", "06/21/2006 21:00", "06/21/2006 21:01", "06/22/2006 02:00", "06/22/2006 02:02", "06/22/2006 07:00", "06/22/2006 12:00", "06/22/2006 12:01", "06/22/2006 17:00", "06/22/2006 17:01", "06/22/2006 22:00", "06/23/2006 03:00", "06/23/2006 08:01", "06/23/2006 13:00", "06/23/2006 13:03", "06/23/2006 18:01", "06/23/2006 18:02", "06/23/2006 23:00", "06/24/2006 04:00", "06/24/2006 09:01", "06/24/2006 14:00", "06/24/2006 19:00", "06/24/2006 19:01", "06/25/2006 00:01", "06/25/2006 05:00", "06/25/2006 10:00", "06/25/2006 10:01", "06/25/2006 15:00", "06/25/2006 15:01", "06/25/2006 20:00", "06/26/2006 01:00", "06/26/2006 01:01", "06/26/2006 06:00", "06/26/2006 11:00", "06/26/2006 11:01", "06/26/2006 16:00", "06/26/2006 21:00", "06/26/2006 21:01", "06/27/2006 02:00", "06/27/2006 07:01", "06/27/2006 12:00", "06/27/2006 17:01", "06/27/2006 22:00", "06/28/2006 03:00", "06/28/2006 08:00", "06/28/2006 08:01", "06/28/2006 13:00", "06/28/2006 18:00", "06/28/2006 23:00", "06/28/2006 23:01", "06/29/2006 04:00", "06/29/2006 09:01", "06/29/2006 14:00", "06/29/2006 19:01", "06/30/2006 00:00", "06/30/2006 00:02", "06/30/2006 05:01", "06/30/2006 10:00", "06/30/2006 10:01", "06/30/2006 15:00", "06/30/2006 20:00", "07/01/2006 01:00", "07/01/2006 06:00", "07/01/2006 06:01", "07/01/2006 11:00", "07/01/2006 11:01", "07/01/2006 16:00", "07/01/2006 21:00", "07/01/2006 21:01", "07/02/2006 02:00", "07/02/2006 07:00", "07/02/2006 12:00", "07/02/2006 17:01", "07/02/2006 22:00", "07/03/2006 03:00", "07/03/2006 03:01", "07/03/2006 08:00", "07/03/2006 13:00", "07/03/2006 18:01", "07/03/2006 23:00", "07/03/2006 23:01", "07/04/2006 04:00", "07/04/2006 09:00", "07/04/2006 09:01", "07/04/2006 14:00", "07/04/2006 14:01", "07/04/2006 19:00", "07/04/2006 19:01", "07/05/2006 00:00", "07/05/2006 05:00", "07/05/2006 05:01", "07/05/2006 10:01", "07/05/2006 15:00", "07/05/2006 20:00", "07/06/2006 01:00", "07/06/2006 01:01", "07/06/2006 06:00", "07/06/2006 06:01", "07/06/2006 11:00", "07/06/2006 11:01", "07/06/2006 16:00", "07/06/2006 21:00", "07/06/2006 21:01", "07/07/2006 02:00", "07/07/2006 07:00", "07/07/2006 12:01", "07/07/2006 17:00", "07/07/2006 22:01", "07/08/2006 03:00", "07/08/2006 08:01", "07/08/2006 13:01", "07/08/2006 18:00", "07/08/2006 18:01", "07/08/2006 23:01", "07/09/2006 04:00", "07/09/2006 09:00", "07/09/2006 14:00", "07/09/2006 19:01", "07/10/2006 00:01", "07/10/2006 05:00", "07/10/2006 10:01", "07/10/2006 15:00", "07/10/2006 15:01", "07/10/2006 20:00", "07/11/2006 01:00", "07/11/2006 01:01", "07/11/2006 06:00", "07/11/2006 06:01", "07/11/2006 11:00", "07/11/2006 11:01", "07/11/2006 16:00", "07/11/2006 21:00", "07/12/2006 02:00", "07/12/2006 02:01", "07/12/2006 07:01", "07/12/2006 12:00", "07/12/2006 12:01", "07/12/2006 17:00", "07/12/2006 17:01", "07/12/2006 22:00", "07/12/2006 22:01", "07/13/2006 03:01", "07/13/2006 08:01", "07/13/2006 08:02", "07/13/2006 13:00", "07/13/2006 13:01", "07/13/2006 18:01", "07/13/2006 23:01", "07/14/2006 04:00", "07/14/2006 04:01", "07/14/2006 09:00", "07/14/2006 09:01", "07/14/2006 14:00", "07/14/2006 14:01", "07/14/2006 19:00", "07/14/2006 19:01", "07/15/2006 00:00", "07/15/2006 00:01", "07/15/2006 05:00", "07/15/2006 10:01", "07/15/2006 15:00", "07/15/2006 15:01", "07/15/2006 20:02", "07/15/2006 20:03", "07/16/2006 01:00", "07/16/2006 01:01", "07/16/2006 06:00", "07/16/2006 06:01", "07/16/2006 11:00", "07/16/2006 11:03", "07/16/2006 16:01", "07/16/2006 21:00", "07/16/2006 21:02", "07/17/2006 02:00", "07/17/2006 02:01", "07/17/2006 07:00", "07/17/2006 07:03", "07/17/2006 12:00", "07/17/2006 12:02", "07/17/2006 17:00", "07/17/2006 22:00", "07/17/2006 22:01", "07/18/2006 03:01", "07/18/2006 08:00", "07/18/2006 08:01", "07/18/2006 13:00", "07/18/2006 18:00", "07/18/2006 23:00", "07/19/2006 04:01", "07/19/2006 09:00", "07/19/2006 09:01", "07/19/2006 14:00", "07/19/2006 19:00", "07/20/2006 00:00", "07/20/2006 00:01", "07/20/2006 05:00", "07/20/2006 05:01", "07/20/2006 10:00", "07/20/2006 15:01", "07/20/2006 20:00", "07/21/2006 01:00", "07/21/2006 06:00", "07/21/2006 11:00", "07/21/2006 11:01", "07/21/2006 16:00", "07/21/2006 16:01", "07/21/2006 21:00", "07/22/2006 02:00", "07/22/2006 07:01", "07/22/2006 12:00", "07/22/2006 17:00", "07/22/2006 17:01", "07/22/2006 22:00", "07/23/2006 03:00", "07/23/2006 08:00", "07/23/2006 13:00", "07/23/2006 18:00", "07/23/2006 23:00", "07/24/2006 04:00", "07/24/2006 04:01", "07/24/2006 09:01", "07/24/2006 14:00", "07/24/2006 19:01", "07/25/2006 00:00", "07/25/2006 00:01", "07/25/2006 05:00", "07/25/2006 05:01", "07/25/2006 10:01", "07/25/2006 15:00", "07/25/2006 15:01", "07/25/2006 20:01", "07/26/2006 01:00", "07/26/2006 01:01", "07/26/2006 06:00", "07/26/2006 11:00", "07/26/2006 16:01", "07/26/2006 21:00", "07/26/2006 21:01", "07/27/2006 02:00", "07/27/2006 02:01", "07/27/2006 07:00", "07/27/2006 07:01", "07/27/2006 12:00", "07/27/2006 17:00", "07/27/2006 22:01", "07/28/2006 03:00", "07/28/2006 03:01", "07/28/2006 08:00", "07/28/2006 08:01", "07/28/2006 13:00", "07/28/2006 18:00", "07/28/2006 23:01", "07/29/2006 04:00", "07/29/2006 04:03", "07/29/2006 09:00", "07/29/2006 14:00", "07/29/2006 19:00", "07/30/2006 00:00", "07/30/2006 00:01", "07/30/2006 05:00", "07/30/2006 05:01", "07/30/2006 10:00", "07/30/2006 10:01", "07/30/2006 15:00", "07/30/2006 20:01", "07/31/2006 01:01", "07/31/2006 01:03", "07/31/2006 06:00", "07/31/2006 06:01", "07/31/2006 11:00", "07/31/2006 11:01", "07/31/2006 16:00", "07/31/2006 21:01"), class = "factor")), .Names = c("ID", “长”,“纬度”,“DT”),类=“data.frame”,row.names = c(1L, 2L、3L、4L、5L、6L、7L、8L、9L、10L、706L、707L、708L、709L、 710L、711L、712L、713L、714L、715L、716L))

I have data that was programmed to acquire information every 5 hours which means multiple data points per day. The problem is sometimes the data logger fails or batteries die or whatever and there are missing data or failed attempts.

All of my analysis I do is based upon these dates. I need to sort and filter and select everything based on this date/time stamp. As of right now I am going through "long winded" scripts just to select and subset my data. Additionally I have several data loggers (individuals) so I am also batch processing. For instance, I want to subset and use only one data point per day and I

    #Subset data by minimum time interval
    SubsetData = T
    MinInterval = 47 #minimum time interval (in hours) between consecutive locations
    ###########
    ##Setting the date and time to be recognized as date time
    loc$DateTime = as.POSIXct(strptime(loc$DT,"%m/%d/%Y %H:%M",tz="UTC"),tz="UTC")
    ### Code to subset data based on minimum time interval between locations
    if (SubsetData ==T){
             row = 0
             EndLoc = 2
             SubData1 = loc[1,]
             IDNames = levels(loc$ID)
    for (n in 1:length(IDNames)){
         IndivData = loc[loc$ID==IDNames[n],]
         row = row+1
         SubData1[row,]=IndivData[1,]
     while (EndLoc<nrow(IndivData) ){
           timediff = difftime(IndivData$DateTime[EndLoc],SubData1$DateTime[row],units = "hours")
   if (timediff>MinInterval){
       row = row+1
       SubData1=rbind(SubData1,IndivData[EndLoc,])
       EndLoc = EndLoc+1
         } else{
               EndLoc = EndLoc+1
              }
         } #end while loop
       } #end loop through individuals
     loc = SubData1
   } #end conditional to subset data
    }
   ### End Code to subset data'

So, is there a way to make my data into time series data to make manipulation easier? Ive seen the discussions for Zoo package a xts - but these seem to require the data to be in regular time series. Ive even had to not use certain scripts because they require the data to be in ts format and I can't figure out how to get my data into that nice formatting. Is there a good resource to teach myself this? Should I even be using ts?

Here is a sample of what my data looks like:
structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("c_002",
"c_402"), class = "factor"), Long = c(-147.635233, -147.635232,
-147.63632, -147.636136, -147.63628, -147.635743, -147.631785,
-147.619598, -147.605088, -147.602119, -147.179737, -147.133275,
-147.106584, -147.033649, -147.016078, -147.031872, -146.940969,
-146.862538, -146.751214, -146.696238, -146.710799), Latitude = c(67.911827,
67.911193, 67.911048, 67.911169, 67.911625, 67.911767, 67.919419,
67.926327, 67.925352, 67.926318, 70.017026, 70.041163, 70.057988,
70.087812, 70.117134, 70.147184, 70.145115, 70.136103, 70.1276,
70.103395, 70.079301), DT = structure(c(2L, 3L, 5L, 6L, 8L, 9L,
10L, 11L, 12L, 14L, 393L, 395L, 396L, 398L, 399L, 401L, 402L,
404L, 405L, 407L, 409L), .Label = c("05/01/2006 00:00", "05/01/2006 00:01",
"05/01/2006 05:00", "05/01/2006 05:01", "05/01/2006 10:00", "05/01/2006 15:01",
"05/01/2006 20:00", "05/01/2006 20:01", "05/02/2006 01:00", "05/02/2006 06:00",
"05/02/2006 11:00", "05/02/2006 16:01", "05/02/2006 21:00", "05/02/2006 21:01",
"05/03/2006 02:00", "05/03/2006 02:01", "05/03/2006 07:00", "05/03/2006 07:01",
"05/03/2006 12:00", "05/03/2006 17:00", "05/03/2006 17:01", "05/03/2006 22:00",
"05/03/2006 22:01", "05/04/2006 03:00", "05/04/2006 03:01", "05/04/2006 08:00",
"05/04/2006 08:01", "05/04/2006 13:00", "05/04/2006 18:00", "05/04/2006 23:00",
"05/04/2006 23:01", "05/05/2006 04:00", "05/05/2006 09:00", "05/05/2006 09:01",
"05/05/2006 14:00", "05/05/2006 19:00", "05/06/2006 00:00", "05/06/2006 00:01",
"05/06/2006 05:00", "05/06/2006 05:01", "05/06/2006 10:00", "05/06/2006 10:01",
"05/06/2006 15:01", "05/06/2006 20:00", "05/06/2006 20:01", "05/07/2006 01:00",
"05/07/2006 01:01", "05/07/2006 06:00", "05/07/2006 06:01", "05/07/2006 11:00",
"05/07/2006 16:00", "05/07/2006 16:01", "05/07/2006 21:00", "05/08/2006 02:00",
"05/08/2006 07:01", "05/08/2006 12:00", "05/08/2006 17:00", "05/08/2006 17:01",
"05/08/2006 22:00", "05/08/2006 22:01", "05/09/2006 03:00", "05/09/2006 03:01",
"05/09/2006 08:00", "05/09/2006 08:01", "05/09/2006 13:00", "05/09/2006 13:01",
"05/09/2006 18:00", "05/09/2006 23:00", "05/09/2006 23:01", "05/10/2006 04:00",
"05/10/2006 04:01", "05/10/2006 09:00", "05/10/2006 09:01", "05/10/2006 14:00",
"05/10/2006 14:01", "05/10/2006 19:00", "05/10/2006 19:03", "05/11/2006 00:00",
"05/11/2006 05:00", "05/11/2006 10:00", "05/11/2006 10:01", "05/11/2006 15:01",
"05/11/2006 15:02", "05/11/2006 20:00", "05/11/2006 20:01", "05/12/2006 01:00",
"05/12/2006 01:01", "05/12/2006 06:00", "05/12/2006 11:00", "05/12/2006 16:00",
"05/12/2006 16:01", "05/12/2006 21:00", "05/12/2006 21:01", "05/13/2006 02:00",
"05/13/2006 07:00", "05/13/2006 07:01", "05/13/2006 12:00", "05/13/2006 17:00",
"05/13/2006 22:00", "05/13/2006 22:01", "05/14/2006 03:00", "05/14/2006 08:00",
"05/14/2006 13:00", "05/14/2006 18:00", "05/14/2006 18:01", "05/14/2006 23:00",
"05/15/2006 04:00", "05/15/2006 04:01", "05/15/2006 09:00", "05/15/2006 09:03",
"05/15/2006 14:00", "05/15/2006 19:00", "05/16/2006 00:00", "05/16/2006 05:01",
"05/16/2006 10:00", "05/16/2006 15:00", "05/16/2006 15:01", "05/16/2006 20:00",
"05/17/2006 01:01", "05/17/2006 01:02", "05/17/2006 06:01", "05/17/2006 11:00",
"05/17/2006 11:01", "05/17/2006 16:00", "05/17/2006 21:00", "05/18/2006 02:00",
"05/18/2006 02:01", "05/18/2006 07:00", "05/18/2006 07:01", "05/18/2006 12:00",
"05/18/2006 12:01", "05/18/2006 17:00", "05/18/2006 22:00", "05/18/2006 22:01",
"05/19/2006 03:00", "05/19/2006 08:00", "05/19/2006 13:01", "05/19/2006 18:00",
"05/19/2006 23:00", "05/19/2006 23:01", "05/20/2006 04:00", "05/20/2006 04:01",
"05/20/2006 09:00", "05/20/2006 09:01", "05/20/2006 14:00", "05/20/2006 14:01",
"05/20/2006 19:00", "05/21/2006 00:01", "05/21/2006 00:02", "05/21/2006 05:00",
"05/21/2006 10:00", "05/21/2006 15:00", "05/21/2006 15:01", "05/21/2006 20:00",
"05/22/2006 01:01", "05/22/2006 06:00", "05/22/2006 11:00", "05/22/2006 11:01",
"05/22/2006 16:00", "05/22/2006 16:01", "05/22/2006 21:00", "05/22/2006 21:01",
"05/23/2006 02:00", "05/23/2006 07:00", "05/23/2006 07:01", "05/23/2006 12:00",
"05/23/2006 17:01", "05/23/2006 22:00", "05/24/2006 03:00", "05/24/2006 08:00",
"05/24/2006 08:01", "05/24/2006 13:00", "05/24/2006 18:00", "05/24/2006 18:01",
"05/24/2006 23:00", "05/24/2006 23:01", "05/25/2006 04:01", "05/25/2006 09:00",
"05/25/2006 09:02", "05/25/2006 14:01", "05/25/2006 19:01", "05/26/2006 00:01",
"05/26/2006 05:00", "05/26/2006 10:00", "05/26/2006 15:00", "05/26/2006 20:00",
"05/27/2006 01:00", "05/27/2006 01:01", "05/27/2006 06:00", "05/27/2006 11:00",
"05/27/2006 16:00", "05/27/2006 16:01", "05/27/2006 21:01", "05/28/2006 02:00",
"05/28/2006 02:01", "05/28/2006 07:00", "05/28/2006 07:01", "05/28/2006 12:01",
"05/28/2006 17:00", "05/28/2006 22:00", "05/29/2006 03:00", "05/29/2006 03:01",
"05/29/2006 08:00", "05/29/2006 13:00", "05/29/2006 13:01", "05/29/2006 18:00",
"05/29/2006 23:01", "05/30/2006 04:00", "05/30/2006 09:00", "05/30/2006 14:00",
"05/30/2006 14:01", "05/30/2006 19:00", "05/30/2006 19:01", "05/31/2006 00:00",
"05/31/2006 00:01", "05/31/2006 05:01", "05/31/2006 10:00", "05/31/2006 10:01",
"05/31/2006 15:00", "05/31/2006 15:01", "05/31/2006 20:00", "06/01/2006 01:00",
"06/01/2006 01:01", "06/01/2006 06:00", "06/01/2006 06:01", "06/01/2006 11:00",
"06/01/2006 11:01", "06/01/2006 16:00", "06/01/2006 21:01", "06/02/2006 02:01",
"06/02/2006 07:00", "06/02/2006 12:00", "06/02/2006 12:01", "06/02/2006 17:00",
"06/02/2006 17:02", "06/02/2006 22:01", "06/03/2006 03:00", "06/03/2006 03:01",
"06/03/2006 08:00", "06/03/2006 08:01", "06/03/2006 13:00", "06/03/2006 13:01",
"06/03/2006 18:00", "06/03/2006 23:00", "06/04/2006 04:00", "06/04/2006 04:01",
"06/04/2006 09:00", "06/04/2006 09:01", "06/04/2006 14:00", "06/04/2006 19:00",
"06/05/2006 00:00", "06/05/2006 05:01", "06/05/2006 10:00", "06/05/2006 15:00",
"06/05/2006 20:00", "06/06/2006 01:00", "06/06/2006 01:01", "06/06/2006 06:01",
"06/06/2006 11:00", "06/06/2006 11:01", "06/06/2006 16:00", "06/06/2006 21:00",
"06/06/2006 21:01", "06/07/2006 02:01", "06/07/2006 07:00", "06/07/2006 07:01",
"06/07/2006 12:00", "06/07/2006 12:01", "06/07/2006 17:00", "06/07/2006 17:01",
"06/07/2006 22:00", "06/07/2006 22:01", "06/08/2006 03:00", "06/08/2006 08:00",
"06/08/2006 08:01", "06/08/2006 13:00", "06/08/2006 13:01", "06/08/2006 18:00",
"06/08/2006 23:00", "06/09/2006 04:00", "06/09/2006 09:00", "06/09/2006 14:00",
"06/09/2006 19:00", "06/10/2006 00:01", "06/10/2006 00:02", "06/10/2006 05:00",
"06/10/2006 10:00", "06/10/2006 15:00", "06/10/2006 20:01", "06/11/2006 01:00",
"06/11/2006 01:01", "06/11/2006 06:00", "06/11/2006 11:00", "06/11/2006 16:00",
"06/11/2006 16:01", "06/11/2006 21:00", "06/12/2006 02:01", "06/12/2006 02:02",
"06/12/2006 07:00", "06/12/2006 07:01", "06/12/2006 12:00", "06/12/2006 17:00",
"06/12/2006 17:01", "06/12/2006 22:00", "06/12/2006 22:01", "06/13/2006 03:00",
"06/13/2006 03:01", "06/13/2006 08:00", "06/13/2006 08:01", "06/13/2006 13:00",
"06/13/2006 13:03", "06/13/2006 18:00", "06/13/2006 18:01", "06/13/2006 23:00",
"06/13/2006 23:01", "06/14/2006 04:00", "06/14/2006 04:01", "06/14/2006 09:00",
"06/14/2006 09:01", "06/14/2006 14:00", "06/14/2006 14:01", "06/14/2006 19:00",
"06/15/2006 00:00", "06/15/2006 05:01", "06/15/2006 10:00", "06/15/2006 15:00",
"06/15/2006 15:01", "06/15/2006 20:00", "06/15/2006 20:01", "06/16/2006 01:01",
"06/16/2006 06:00", "06/16/2006 06:01", "06/16/2006 11:00", "06/16/2006 11:01",
"06/16/2006 16:00", "06/16/2006 16:01", "06/16/2006 21:00", "06/16/2006 21:01",
"06/17/2006 02:00", "06/17/2006 07:00", "06/17/2006 07:01", "06/17/2006 12:00",
"06/17/2006 12:01", "06/17/2006 17:00", "06/17/2006 22:00", "06/18/2006 03:00",
"06/18/2006 03:01", "06/18/2006 08:01", "06/18/2006 13:00", "06/18/2006 13:01",
"06/18/2006 18:01", "06/18/2006 23:00", "06/19/2006 04:00", "06/19/2006 04:01",
"06/19/2006 09:00", "06/19/2006 09:01", "06/19/2006 14:01", "06/19/2006 19:01",
"06/20/2006 00:00", "06/20/2006 05:00", "06/20/2006 05:01", "06/20/2006 10:01",
"06/20/2006 15:00", "06/20/2006 15:01", "06/20/2006 20:00", "06/21/2006 01:00",
"06/21/2006 01:01", "06/21/2006 06:00", "06/21/2006 06:01", "06/21/2006 11:01",
"06/21/2006 16:00", "06/21/2006 16:01", "06/21/2006 21:00", "06/21/2006 21:01",
"06/22/2006 02:00", "06/22/2006 02:02", "06/22/2006 07:00", "06/22/2006 12:00",
"06/22/2006 12:01", "06/22/2006 17:00", "06/22/2006 17:01", "06/22/2006 22:00",
"06/23/2006 03:00", "06/23/2006 08:01", "06/23/2006 13:00", "06/23/2006 13:03",
"06/23/2006 18:01", "06/23/2006 18:02", "06/23/2006 23:00", "06/24/2006 04:00",
"06/24/2006 09:01", "06/24/2006 14:00", "06/24/2006 19:00", "06/24/2006 19:01",
"06/25/2006 00:01", "06/25/2006 05:00", "06/25/2006 10:00", "06/25/2006 10:01",
"06/25/2006 15:00", "06/25/2006 15:01", "06/25/2006 20:00", "06/26/2006 01:00",
"06/26/2006 01:01", "06/26/2006 06:00", "06/26/2006 11:00", "06/26/2006 11:01",
"06/26/2006 16:00", "06/26/2006 21:00", "06/26/2006 21:01", "06/27/2006 02:00",
"06/27/2006 07:01", "06/27/2006 12:00", "06/27/2006 17:01", "06/27/2006 22:00",
"06/28/2006 03:00", "06/28/2006 08:00", "06/28/2006 08:01", "06/28/2006 13:00",
"06/28/2006 18:00", "06/28/2006 23:00", "06/28/2006 23:01", "06/29/2006 04:00",
"06/29/2006 09:01", "06/29/2006 14:00", "06/29/2006 19:01", "06/30/2006 00:00",
"06/30/2006 00:02", "06/30/2006 05:01", "06/30/2006 10:00", "06/30/2006 10:01",
"06/30/2006 15:00", "06/30/2006 20:00", "07/01/2006 01:00", "07/01/2006 06:00",
"07/01/2006 06:01", "07/01/2006 11:00", "07/01/2006 11:01", "07/01/2006 16:00",
"07/01/2006 21:00", "07/01/2006 21:01", "07/02/2006 02:00", "07/02/2006 07:00",
"07/02/2006 12:00", "07/02/2006 17:01", "07/02/2006 22:00", "07/03/2006 03:00",
"07/03/2006 03:01", "07/03/2006 08:00", "07/03/2006 13:00", "07/03/2006 18:01",
"07/03/2006 23:00", "07/03/2006 23:01", "07/04/2006 04:00", "07/04/2006 09:00",
"07/04/2006 09:01", "07/04/2006 14:00", "07/04/2006 14:01", "07/04/2006 19:00",
"07/04/2006 19:01", "07/05/2006 00:00", "07/05/2006 05:00", "07/05/2006 05:01",
"07/05/2006 10:01", "07/05/2006 15:00", "07/05/2006 20:00", "07/06/2006 01:00",
"07/06/2006 01:01", "07/06/2006 06:00", "07/06/2006 06:01", "07/06/2006 11:00",
"07/06/2006 11:01", "07/06/2006 16:00", "07/06/2006 21:00", "07/06/2006 21:01",
"07/07/2006 02:00", "07/07/2006 07:00", "07/07/2006 12:01", "07/07/2006 17:00",
"07/07/2006 22:01", "07/08/2006 03:00", "07/08/2006 08:01", "07/08/2006 13:01",
"07/08/2006 18:00", "07/08/2006 18:01", "07/08/2006 23:01", "07/09/2006 04:00",
"07/09/2006 09:00", "07/09/2006 14:00", "07/09/2006 19:01", "07/10/2006 00:01",
"07/10/2006 05:00", "07/10/2006 10:01", "07/10/2006 15:00", "07/10/2006 15:01",
"07/10/2006 20:00", "07/11/2006 01:00", "07/11/2006 01:01", "07/11/2006 06:00",
"07/11/2006 06:01", "07/11/2006 11:00", "07/11/2006 11:01", "07/11/2006 16:00",
"07/11/2006 21:00", "07/12/2006 02:00", "07/12/2006 02:01", "07/12/2006 07:01",
"07/12/2006 12:00", "07/12/2006 12:01", "07/12/2006 17:00", "07/12/2006 17:01",
"07/12/2006 22:00", "07/12/2006 22:01", "07/13/2006 03:01", "07/13/2006 08:01",
"07/13/2006 08:02", "07/13/2006 13:00", "07/13/2006 13:01", "07/13/2006 18:01",
"07/13/2006 23:01", "07/14/2006 04:00", "07/14/2006 04:01", "07/14/2006 09:00",
"07/14/2006 09:01", "07/14/2006 14:00", "07/14/2006 14:01", "07/14/2006 19:00",
"07/14/2006 19:01", "07/15/2006 00:00", "07/15/2006 00:01", "07/15/2006 05:00",
"07/15/2006 10:01", "07/15/2006 15:00", "07/15/2006 15:01", "07/15/2006 20:02",
"07/15/2006 20:03", "07/16/2006 01:00", "07/16/2006 01:01", "07/16/2006 06:00",
"07/16/2006 06:01", "07/16/2006 11:00", "07/16/2006 11:03", "07/16/2006 16:01",
"07/16/2006 21:00", "07/16/2006 21:02", "07/17/2006 02:00", "07/17/2006 02:01",
"07/17/2006 07:00", "07/17/2006 07:03", "07/17/2006 12:00", "07/17/2006 12:02",
"07/17/2006 17:00", "07/17/2006 22:00", "07/17/2006 22:01", "07/18/2006 03:01",
"07/18/2006 08:00", "07/18/2006 08:01", "07/18/2006 13:00", "07/18/2006 18:00",
"07/18/2006 23:00", "07/19/2006 04:01", "07/19/2006 09:00", "07/19/2006 09:01",
"07/19/2006 14:00", "07/19/2006 19:00", "07/20/2006 00:00", "07/20/2006 00:01",
"07/20/2006 05:00", "07/20/2006 05:01", "07/20/2006 10:00", "07/20/2006 15:01",
"07/20/2006 20:00", "07/21/2006 01:00", "07/21/2006 06:00", "07/21/2006 11:00",
"07/21/2006 11:01", "07/21/2006 16:00", "07/21/2006 16:01", "07/21/2006 21:00",
"07/22/2006 02:00", "07/22/2006 07:01", "07/22/2006 12:00", "07/22/2006 17:00",
"07/22/2006 17:01", "07/22/2006 22:00", "07/23/2006 03:00", "07/23/2006 08:00",
"07/23/2006 13:00", "07/23/2006 18:00", "07/23/2006 23:00", "07/24/2006 04:00",
"07/24/2006 04:01", "07/24/2006 09:01", "07/24/2006 14:00", "07/24/2006 19:01",
"07/25/2006 00:00", "07/25/2006 00:01", "07/25/2006 05:00", "07/25/2006 05:01",
"07/25/2006 10:01", "07/25/2006 15:00", "07/25/2006 15:01", "07/25/2006 20:01",
"07/26/2006 01:00", "07/26/2006 01:01", "07/26/2006 06:00", "07/26/2006 11:00",
"07/26/2006 16:01", "07/26/2006 21:00", "07/26/2006 21:01", "07/27/2006 02:00",
"07/27/2006 02:01", "07/27/2006 07:00", "07/27/2006 07:01", "07/27/2006 12:00",
"07/27/2006 17:00", "07/27/2006 22:01", "07/28/2006 03:00", "07/28/2006 03:01",
"07/28/2006 08:00", "07/28/2006 08:01", "07/28/2006 13:00", "07/28/2006 18:00",
"07/28/2006 23:01", "07/29/2006 04:00", "07/29/2006 04:03", "07/29/2006 09:00",
"07/29/2006 14:00", "07/29/2006 19:00", "07/30/2006 00:00", "07/30/2006 00:01",
"07/30/2006 05:00", "07/30/2006 05:01", "07/30/2006 10:00", "07/30/2006 10:01",
"07/30/2006 15:00", "07/30/2006 20:01", "07/31/2006 01:01", "07/31/2006 01:03",
"07/31/2006 06:00", "07/31/2006 06:01", "07/31/2006 11:00", "07/31/2006 11:01",
"07/31/2006 16:00", "07/31/2006 21:01"), class = "factor")), .Names = c("ID",
"Long", "Latitude", "DT"), class = "data.frame", row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 706L, 707L, 708L, 709L,
710L, 711L, 712L, 713L, 714L, 715L, 716L))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最美的太阳 2024-11-24 00:24:03

库(zoo)可以处理不规则的时间序列,并且正如 Gabor 所说,Zoo FAQ 具有每天聚合多个观察结果的方法:

z <- zoo( x=data.frame(....), order.by=loc$DateTime ) # translate 'loc' into zoo somehow 

za <- aggregate(z, identity, mean)  # take the mean of identically timed objects 

...并用局部拟合数据填充缺失的数据:

g  <- seq(start(z),end(z),by=1/frequency(z)) 
zi <- na.locf(z,xout=g)

library(zoo) can deal with irregular time series, and, as Gabor said, the Zoo FAQ has methods for aggregating multiple observations per day:

z <- zoo( x=data.frame(....), order.by=loc$DateTime ) # translate 'loc' into zoo somehow 

za <- aggregate(z, identity, mean)  # take the mean of identically timed objects 

...and fill in missing data with locally fit data:

g  <- seq(start(z),end(z),by=1/frequency(z)) 
zi <- na.locf(z,xout=g)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文