famuvie / breedR

Statistical methods for forest genetic resources analysts
http://famuvie.github.io/breedR/
GNU General Public License v3.0
31 stars 24 forks source link

bug in function parser when results are NaN #78

Open famuvie opened 7 years ago

famuvie commented 7 years ago

Within parse_functions(), which is defined within parse_results() there is this function parser:

    parse_function <- function(x) {
      pick_nmbr <- function(x) {
        conv <- suppressWarnings(as.numeric(x))
        stopifnot(sum(idx <- !is.na(conv)) == 1)
        return(conv[idx])
      }
      structure(sapply(strsplit(x, ' '), pick_nmbr),
                names = c('mean', 'sample mean', 'sample sd'))
    }

Which usually takes character vectors of the form:

c("  Mean:   0.28419    ", "  Sample Mean:   0.28229    ", "  Sample SD:   0.10392    ")

However, when any one of the numbers is NaN, the defensive condition is fired.

I have seen this happening whenever some of the relevant variances are small, leading to numerical issues.

famuvie commented 7 years ago