将 H2OFrame 对象从毫秒转换为分钟?
Convert H2OFrame object from milliseconds to Minutes?
H2O-R-Package 正在为 extract/convert 个 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() 函数?
我找到了一个更好的模数解决方案:
data.hex = h2o.importFile(filetoload, sep = "," )
date.hex = data.hex[,3]
#Number of minutes since the begining of Hour
#Divide by 1000 to work with seconds and Extract minutes + seconds
#Remove seconds and format in minutes
minu.hex = ((date.hex/1000)%%(60*60))%/%60
H2O-R-Package 正在为 extract/convert 个 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() 函数?
我找到了一个更好的模数解决方案:
data.hex = h2o.importFile(filetoload, sep = "," )
date.hex = data.hex[,3]
#Number of minutes since the begining of Hour
#Divide by 1000 to work with seconds and Extract minutes + seconds
#Remove seconds and format in minutes
minu.hex = ((date.hex/1000)%%(60*60))%/%60