2017-08-24 33 views
0

一個數據幀的可變我有一個數據幀,其包括定時數據獲取lubridate時間對象的最大值,時間列包括的lubridate::hms()目的,現在如何可以從得到最大時間對象值在R.如何從R中

可變時間

Snapshot of the data frame 我試圖做到這一點通過這個基本方法,但它在雙格式 - 返回值>

> max(comdty1$Time) 
[1] 59.99531 

也這是好的

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

TIA

+0

解決你嘗試'MAX(lubridate :: HMS(comdty1 $時間))'? – meenaparam

+0

Does'nt works .... > max(hms(comdty1 $ Time)) [1]不適用 –

回答

0

這是我想出了

# get the maximum hour 
maxHour1 <- max(hour(comdty1$Time)) 
# get the corresponding complete time object 
tail(comdty1$Time[which(hour(comdty1$Time)==TmaxHour)],1)