alkIndivAge() fails if any of the lengths in the length sample were not recorded. It makes sense that it cannot assign an age using the ALK if there is no length. However, the error is largely uninterpretable:
Error in `[<-.data.frame`(`*tmp*`, data$TMPLCAT == i, ca, value = c(4, :
missing values are not allowed in subscripted assignments of data frames
Thus, we should perform a pre-check for this and if NAs exist return a useful error message that indicates the problem and suggests that the user filter out those individuals.
Demonstration of The Problem
The following code from the documentation for alkIndivAge() runs without error:
The problem
alkIndivAge()
fails if any of the lengths in the length sample were not recorded. It makes sense that it cannot assign an age using the ALK if there is no length. However, the error is largely uninterpretable:Thus, we should perform a pre-check for this and if
NA
s exist return a useful error message that indicates the problem and suggests that the user filter out those individuals.Demonstration of The Problem
The following code from the documentation for
alkIndivAge()
runs without error:However, if the length sample is modified to include a fish without a measured length ...
Then the last line above modified to use the modified length sample data frame will produce the error shown above.
Possible Fix
The following lines inserted above line 124 in alkIndivAge.R (above where the random seed may be set) may fix this issue.