Closed droglenc closed 3 years ago
is.wholenumber() in bazar and is.whole() in bgr check for numeric when checking for whole number. Suggest doing the same. Submitting the next two lines to FSA: ct3=c("one","two","three") removal(ct3) returns "Error in sum(ct3) : invalid 'type' (character) of arguments. The error is being thrown on line 254 of removal.R during internal calculations of intermediate values Suggest adding a check for numeric when checking for integer. Return error when non-numeric value found and warning when numeric but not whole number.
Your ct3
example brings up several issues with the "checks" at the beginning of removal()
. Some thoughts about how to proceed ...
as.numeric()
when converting a one row or one column matrix or a one column data.frame for use is problematic. For example, as.numeric(data.frame(words=c("one","two","three")))
will throw a "cannot be coerced" error. I think that the the matrix correction (current line 212) should condition on if it is only one row or one column and if it is a row then do catch <- catch[1,]
and if it is a row then do catch <- catch[,1]
. For the data.frame correction (current line 214) we should use catch <- catch[[,1]]
.removal
requires numeric data."FSA
was "bloated" because too many other packages were loaded with FSA
). In this vein, I think we should make an internal function called iIsWhole()
(will be in the FSAInternals.R
file that is the code for is.wholeNumber()
in the documentation for is.integer()
. We can then use that function here. I think we can make it internal because the world does not need another whole number function.NA
s and catches of 1 as in the current code.Relatedly ...
Tmult=
check right below where conf.level=
is checked and thus above where the checking of catch
starts. This way the simple things that will kill the function appear first, then we get into the more involved checking of catch
.conf.level=
and this can be shared across several other functions. See #66.
The
removal()
function is primarily used with catch of individuals data. Thus, the data should generally be whole numbers that are positive. Consider adding a check for whole numbers and throwing a warning, not an error (as some have usedremoval()
to estimate biomass and thus have used non-whole numbers). Do not useis.integer()
. Look atis.whole()
in several other packages.