Skip to content
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

Changed Duration format to correctly display negative values #746

Conversation

hglanz
Copy link

@hglanz hglanz commented Jan 19, 2019

Fixes #719

hglanz and others added 4 commits January 19, 2019 10:50
…h negative values

Negative durations were not being printed properly; they looked positive. This one line addition prepends a negative sign to durations created from negative values.

When the package is tested I get 4 failures, but I get these same 4 failures with no changes to the package code. So, I'm unsure how to resolve this.
@hadley hadley changed the title Issue #719 - Changed Duration format to correctly display negative va… Changed Duration format to correctly display negative values Nov 19, 2019
@hadley
Copy link
Member

hadley commented Nov 19, 2019

If, you're interested in finishing this off, would you mind add a small unit test? No worries, if you're not, just let me know and I'll get it over the finish line for you.

@hglanz
Copy link
Author

hglanz commented Nov 21, 2019

I can definitely put a unit test together for this! Thanks for taking a look. Would you mind if I don't get to it for a couple of days? If you do, then I'm perfectly happy for you to take it over the finish line...I don't want to hold anything up.

@hadley
Copy link
Member

hadley commented Nov 21, 2019

No rush!

@@ -101,6 +101,7 @@ format.Duration <- function(x, ...) {
out <- vector("character", length(x@.Data))
nnas <- !is.na(x@.Data)
out[nnas] <- compute_estimate(abs(x@.Data[nnas]))
out[nnas] <- ifelse(x@.Data[nnas] < 0, paste0("-", out[nnas]), out[nnas])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this negative sign should be handled in compute_estimate instead and that abs removed.

@vspinu
Copy link
Member

vspinu commented Dec 7, 2019

I have fixed this at the root in compute_estimate. Thanks for pushing through!

@vspinu vspinu closed this Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negative durations are displayed as positive
3 participants