Abhinav Rawat Abhinav Rawat - 5 months ago 62
R Question

How to get max value of lubridate time object from a variable of a data frame in R

I have a data frame which includes timed data, the time column includes object of

, now how can get the max time object value from the variable time in R.

Snapshot of the data frame
I was trying do it by this basic approach, but it returns value in double format->

> max(comdty1$Time)
[1] 59.99531

also this is fine

> max(lubridate::hour(comdty1$Time))
[1] 17


Answer Source

This is the solution I came up with

# get the maximum hour
maxHour1 <- max(hour(comdty1$Time))
# get the corresponding complete time object
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download