-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rounding to tenth of a second doesn't work #502
Comments
Yeh. Fractional seconds and other units are not supported (yet). Need to throw an error here. |
Hello! I was about to submit a request for rounding at the milliseconds level but I see this issue is already being raised here. Any plans on implementing this soon? This feature is very important - a promising package such as lubridate just cannot afford not to have this sub-second rounding. Thanks! |
summoning @hadley @vspinu @archenemies :D |
@randomgambit: I have to say that I find your rhetoric amusing, but I agree with you in principle; there is no reason why this library shouldn't be able to round to fractional seconds. Implementing that should be much easier than what's already implemented - rounding to hours, months, years, 15 minutes, etc. However, I haven't had very good luck getting @hadley to respond to bugs in his libraries. He's too busy writing more libraries! I would suggest that you try working around the problem, or copy-pasting the relevant code into your package and fixing it yourself. |
thanks for your feedback! I see your point but this does not make sense to me. What is the purpose of having a I am coming from Python where I mostly used Pandas. In my humble opinion Pandas is superior to dplyr EXCEPT in two points:
In particular, I feel the In any case, dont misundertand me. R is great, the |
@randomgambit: I appreciated learning about the Python world. I'm attaching my workaround, in case anyone is interested. Here's a diff so you can see what I changed: The diff is against this file, which just has copies of the original "lubridate" functions: |
This conversation doesn't seem to be going anywhere useful so I've locked it for now. We'll look at the original issue when we next prepare for a release. |
This was fixed in #519, but documented only now. Rounding to fractions of a second is a very imprecise operation due to limited precision of POSIXct objects (double). Even rounding to > as.POSIXct("2009-08-03 12:01:59.3")
[1] "2009-08-03 12:01:59.2 CEST"
>
> (x <- ymd_hms("2009-08-03 12:01:59.23"))
[1] "2009-08-03 12:01:59.23 UTC"
> ceiling_date(x, ".1 sec")
[1] "2009-08-03 12:01:59.2 UTC" |
It's actually a bug in POSIXt printing methods.: > (x <- as.POSIXct("2009-08-03 12:01:59.3"))
[1] "2009-08-03 12:01:59.2 CEST"
> as.numeric(x)
[1] 1249293719.3 Double precision is actually pretty good in that range. |
I would expect
floor_date(...,"0.1 seconds")
to either floor my date to the nearest tenth of a second, or throw an error. It does neither:The problem seems to be in
parse_period_unit
:The text was updated successfully, but these errors were encountered: