R issue with rounding milliseconds

前端 未结 4 1233
孤街浪徒
孤街浪徒 2020-12-18 00:46

Given the following issue with rounding milliseconds under R. How do I get around it so that the times are correct?

> options(digits.secs=3)
> as.POSI         


        
4条回答
  •  遥遥无期
    2020-12-18 01:33

    The milliseconds are there:

     unclass(as.POSIXlt("13:29:56.061", '%H:%M:%OS', tz='UTC'))
     $sec
     [1] 56.061
     ...
    

    (There's no need to call format here, it's the name of an argument not the required input from some other function).

    Otherwise, I cannot reproduce (on Windows 64-bit R 2.15.0):

    options(digits.secs = 3)
    as.POSIXlt("13:29:56.061", '%H:%M:%OS', tz='UTC')
    [1] "2012-06-07 13:29:56.061 UTC"
    
    sessionInfo()
    R version 2.15.0 Patched (2012-05-05 r59321)
    Platform: x86_64-pc-mingw32/x64 (64-bit)
    ...
    

提交回复
热议问题