Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upWrong units displayed in data.table with POSIXct arithmetic #761
Comments
This comment has been minimized.
This comment has been minimized.
Agreed it's a bug. Thanks for the nice report. I tested in latest dev just now and it occurs there too. Good to have the S.O. question as well i.e. don't take it down. More chance people will find it and see the workarounds etc. As a first step, the attributes on each group result could be checked for consistency and a warning issued if not. I thought it did that already but clearly not. Tagged High for the this detection and warning aspect which should be relatively straightforward and could be an issue in other cases unrelated to POSIXct. Making it return the right result without speed penalty could be hard, so likely best to have user call difftime(,units=), and that could be a suggestion in the warning message. |
This comment has been minimized.
This comment has been minimized.
Was just trying to figure out if I couldn't fix this, but it seems the mistake is done entirely in C (everything's fine up until |
This comment has been minimized.
This comment has been minimized.
Some more details copied as this re-surfaced for me:
The problem is that These units are ignored on group wrapup:
|
This comment has been minimized.
This comment has been minimized.
Closed by #3837. |
This comment has been minimized.
This comment has been minimized.
oh really? I believe that works in the commit message... or maybe that's just gitlab? |
This comment has been minimized.
This comment has been minimized.
Yep. I don't know about gitlab or the commit message (I don't think so), but this one did not close this one. Before merge you can see if the merge is going to close it or not via a hyperlink / tooltip that appears in the linked PR on the issue labeled "will be closed by" (or similar). |
This comment has been minimized.
This comment has been minimized.
OK. something to raise with GitHub |
Recently posted on StackOverflow because didn't know how to report bug report / make feature request here.
http://stackoverflow.com/questions/25214170/wrong-units-displayed-in-data-table-with-posixct-arithmetic
Problem reproduced here for completeness, I can take down SO "question" if this bug is deemed legitimate here:
When durations are computed in data.table (v1.9.2), the wrong units can be printed with POSIXct arithmetic. It seems the first units are chosen.
I realize that one of these is the correct way to do it to get expected behavior, but wanted to report this behavior. Not sure if it is really a data.table problem or POSIXct problem.