R-Lum / Luminescence

Development of the R package 'Luminescence'
http://r-lum.github.io/Luminescence/
GNU General Public License v3.0
15 stars 7 forks source link

wrong computation of n_breaks in calc_WodaFuchs2008() #197

Closed mcol closed 2 months ago

mcol commented 2 months ago

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

https://github.com/R-Lum/Luminescence/blob/759a1142651cc557f9fd06c6b061d1aff244cdf9/R/calc_WodaFuchs2008.R#L121-L124

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

RLumSK commented 2 months ago

OK

mcol commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

Fixed by #198.