R-Lum/Luminescence

calc_CentralDose: NaN, NA values must be excluded

Closed this issue · 4 comments

Expected behaviour

it works, great!

Observed behaviour

error!

Running mini example

t <- data.frame(rnorm(10)+5, rnorm(10)+5); t[2,1] = NaN
calc_CentralDose(t)

library(Luminescence)

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ‘"try-error"’ to a data.frame

basically, it stumbles on NaN. Also with a NA value

the code should remove the offending row, then calculate the CAM value

You will find that all functions will crash if you provide the wrong input. Besides, I see your point.

I added a new argument na.rm which is (R canon) by default set to FALSE. However, NA values will not break the function anymore but return just NA.

Your comments and contributions are highly welcome. So don't worry.

When it comes down to R, it works differently. What you want is something that can be done quickly with a GUI, but this is nothing R is made for. Implementing all those tests is not only tedious work, which might be justified; it also costs a lot in terms of overhead. For some functions, it makes sense, calc_CentralDose() is one of them, but for others, it does not scale nicely.

Why would analyse_SAR.CWOSL provides NaN, for the De, but manages to provides a positive uncertainty, should be left for another time, in another < issue >.

This is because the fitting obviously failed, however, for the MC runs (the error estimation), some of the fitting worked. Not nice, but it may happen.