简体   繁体   中英

Change Factor to Time for FFDF Object in R

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 .

Example of D_Time are as follow:

> 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

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提供此解决方案:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM