Change Factor to Time for FFDF Object in R

2019-08-27 11:31发布

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.

标签: r time
1条回答
Deceive 欺骗
2楼-- · 2019-08-27 12:35

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)
查看更多
登录 后发表回答