Abhinav Rawat - 2 months ago 34

R Question

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

`lubridate::hms()`

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

TIA

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
tail(comdty1$Time[which(hour(comdty1$Time)==TmaxHour)],1)
```