【发布时间】:2018-05-17 15:05:16
【问题描述】:
H2O-R-Package 提供了将 H2OFrame 对象的条目从毫秒提取/转换为:
- 年份 h2o.year()
- 月 h2o.month()
- 小时 h2o.hour()
- 天 h2o.day()
- 星期几 h2o.dayOfWeek()
- 但几分钟内什么都没有......
如何将 H2OFrame 对象的条目从小时开始的毫秒转换为分钟?
data.hex = h2o.importFile(filetoload, sep = "," )
date.hex = data.hex[,3]
#Number of minutes since the begining of Hour
date_epoch = as.data.frame(date.hex)
date_formated = apply(date_epoch , 1, function(x){
date_format = as.POSIXlt(x, origin="1970-01-01", tz="HKT")
return(date_format)
} )
minu = unlist(lapply(date_formated, function(x){
return(x$min)
}))
minu.hex = as.h2o(minu)
这段代码的计算时间非常长:
#Hour of day
heure.hex = hour(date.hex)
有没有更好的解决方案? 为什么没有 h2o.minute() 函数?
【问题讨论】: