在 R 中将 FFDF 对象的因子更改为时间

编程入门 行业动态 更新时间:2024-10-27 12:33:33
本文介绍了在 R 中将 FFDF 对象的因子更改为时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有一个名为 Affdf 对象,带有 (dim=c(26416266,25)).我正在尝试将时间变量 (D_Time)Factor 类型转换为 Time,以便我可以执行 summary() 并获取D_Time最小值、最大值、平均值和中值.

I have a ffdf objects named A with (dim=c(26416266,25)). I'm trying to convert the Time variable (D_Time) from type Factor to Time, so that I can perform summary() and get the min, max, average and median for D_Time.

D_Time 示例如下:

> D_Time
1     07:40
2     08:01
3     02:24
4     08:15
5     01:45
6     04:56
7     02:12
8     07:35
9     05:48
10    11:50

我已尝试将 A 更改为 dataframe 并使用 chron 进行转换,但我的内存不足.我尝试使用 chron, POSIXlt 但不断收到错误消息.我也尝试将 :00 粘贴为 ss 以制作 hh:mm:ss 格式,但仍然没有运气.

I have try to change A to dataframe and convert it using chron but my memory is running out. I try to use chron, POSIXlt but keep getting error message. I also try to paste :00 as ss to make the format hh:mm:ss but still no luck.

我想知道,有没有办法做到这一点?提前致谢.

I'm wonder, is there any way to do this? Thanks in advance.

推荐答案

感谢@jwijffels 提供此解决方案:

Credit to @jwijffels for this solution:

A$D_DateTime <- with(A, as.POSIXct(paste(D_Date, D_Time, sep=" "), format = "%Y-%m-%d %H:%M"), by = 250000)

这篇关于在 R 中将 FFDF 对象的因子更改为时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 12:22:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1393513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:因子   中将   对象   时间   FFDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!