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

wrong computation of n_breaks in calc_WodaFuchs2008() #197

Closed
mcol opened this issue Sep 4, 2024 · 4 comments
Closed

wrong computation of n_breaks in calc_WodaFuchs2008() #197

mcol opened this issue Sep 4, 2024 · 4 comments

Comments

@mcol
Copy link
Contributor

mcol commented Sep 4, 2024

The division is misplaced, as it operates only on min(.) rather than on max(.) - min(.)

n_breaks <- (max(data[,1],
na.rm = TRUE) -
min(data[,1],
na.rm = TRUE) / bin_width)

This can be more compactly be rewritten as diff(range(.)) / bin_width.

@mcol mcol added this to the v0.9.25 (autumn CRAN release) milestone Sep 4, 2024
@RLumSK
Copy link
Member

RLumSK commented Sep 4, 2024

OK

@mcol
Copy link
Contributor Author

mcol commented Sep 4, 2024

Example of failure as as it computes n_breaks = -15.71539 :

data(ExampleData.Fading)
calc_WodaFuchs2008(ExampleData.Fading$fading.data$IR50)
# Error in hist.default(x = data[, 1], breaks = n_breaks, plot = FALSE) : 
#  invalid number of 'breaks'

@mcol
Copy link
Contributor Author

mcol commented Sep 4, 2024

Even simpler:

set.seed(1)
calc_WodaFuchs2008(data.frame(rnorm(20, 10), rnorm(20, 0.5)))
# Error in hist.default(x = data[, 1], breaks = n_breaks, plot = FALSE) : 
#  invalid number of 'breaks'

@mcol
Copy link
Contributor Author

mcol commented Sep 4, 2024

Fixed by #198.

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

No branches or pull requests

2 participants