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
percent() with zero value yields NaN #50
Comments
The problem ultimately arises because # not real code because we are talking about a function in another package.
plyr:::round_any.numeric
function (x, accuracy, f = round)
{
if(accuracy == 0) {
x
} else {
f(x/accuracy) * accuracy
}
} |
I think that is a good solution. |
@BrianDiggs I suspect there's a better rounding algorithm that will also work with small x. Hopefully twitter can help: http://twitter.com/hadleywickham/status/608679186597695488 |
Any update on this?
|
I must say it is embarrassing that this bug happened in the first place but it is more embarrassing that it is not fixed. I nearly had a report going out with "NaN%" in there. Sorry, if this comes across angry, but it makes me sad when you can't rely on these easy things. my.percent<- function(x) { |
IMO, the precision() function (which is used only by percent()) should be improved:
precision(0) should return 1 (this would fix the issue here), but for the other two I'm not sure. |
Could use mvpp's observation for a fix by creating a vector with dummy value and using only first numeric e.g., |
The text was updated successfully, but these errors were encountered: