H2O-R-Package提供的功能是将H2OFrame对象的条目从毫秒提取/转换为:
自小时开始以来,如何将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()函数?
答案 0 :(得分:1)
我使用modulo找到了更好的解决方案:
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