简体   繁体   中英

parsing seconds to mm.ss.00 in r

I want to convert seconds (performance times)into a mm.ss.00 format. Ideally I'm planning on keeping it in a numerical data format and not a time string (HH.MM.SS etc) so that I can analyses on it using satisitcal models etc.

was hopefull to find a package that could do this for me but with no luck. doing simple math dosent quite give me what im after (eg. dividing by 60).

 Distance.km Planned.Time Actual.Time
  <chr>              <dbl>       <dbl>
1 1                   66.4        65.7
2 2                  126.        128. 
3 3                  186.        192. 
4 4                   NA          NA  

Many Thanks

EDIT:

data format I'm trying to achieve is for exmaple 1.06.4 converted from 66.4 seconds

Try lubridate::seconds_to_period which returns a Period object.

lubridate::seconds_to_period(df$Planned.Time)
#[1] "1M 6.40000000000001S" "2M 6S"      "3M 6S"          NA    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM