全部版块 我的主页
论坛 休闲区 十二区 灌水吧
227 0
2022-11-04
[color=rgba(0, 0, 0, 0.75)]

我有一个包含不完整日期时间变量的数据框。数据的间隔是0.5秒。我想找出丢失的时间点并为每个丢失的时间点插入一条记录。例如,数据如下所示:

  • [color=rgb(119, 120, 136) !important]




  • [color=rgb(119, 120, 136) !important]


    df <- structure(list(time = structure(c(1652182189, 1652182189, 1652182190, 1652182191

  • [color=rgb(119, 120, 136) !important]


    ), class = c("POSIXct", "POSIXt"), tzone = ""), positionx = 3:6),

  • [color=rgb(119, 120, 136) !important]


    row.names = c(NA, -4L), class = "data.frame")


我尝试用 pad() 解决它。

  • [color=rgb(119, 120, 136) !important]


    pad(df, interval = " .5 sec")

  • [color=rgb(119, 120, 136) !important]





但是,由于pad()的间隔的最小单位是秒,所以会出现如下错误。

  • [color=rgb(119, 120, 136) !important]


    Error: interval is not valid.

  • [color=rgb(119, 120, 136) !important]





我想填充数据框如下。如何解决这个问题呢?请给我一些建议~

  • [color=rgb(119, 120, 136) !important]


      time                positionx

  • [color=rgb(119, 120, 136) !important]


      <dttm>                  <int>

  • [color=rgb(119, 120, 136) !important]


    1 2022-05-10 19:29:49         3

  • [color=rgb(119, 120, 136) !important]


    2 2022-05-10 19:29:49         4

  • [color=rgb(119, 120, 136) !important]


    3 2022-05-10 19:29:50         5

  • [color=rgb(119, 120, 136) !important]


    4 2022-05-10 19:29:50        NA

  • [color=rgb(119, 120, 136) !important]


    5 2022-05-10 19:29:51         6

  • [color=rgb(119, 120, 136) !important]











  • 好问题

    提建议

  • 追加酬金
  • 分享

  • 邀请回答




[color=rgba(0, 0, 0, 0.75)]





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群