楼主: xiaoluxia
226 0

如何填充数据框的日期时间列? [推广有奖]

  • 0关注
  • 0粉丝

小学生

50%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
133 点
帖子
3
精华
0
在线时间
11 小时
注册时间
2020-8-5
最后登录
2024-10-23

楼主
xiaoluxia 发表于 2022-11-4 14:51:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
[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)]





二维码

扫码加我 拉你入群

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

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

关键词:数据框 IMPORTANT import porta Port

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2025-12-29 18:36