Closed droglenc closed 3 years ago
I think the issue is related to this line ...
tmpdf <- data[data[,2]==specs[i],]
as the species with NA
get carried along with this such that tmpdf
does not contain just specs[i]
(it also contains species==NA). I think that I can fix this by pulling off the NA species first and then adding them back in after the other species have been worked through.
Will be fixed in v0.8.32
In short, I have two issues related to situations where there is a species=NA in the data frame. First, the species=NA generates an NA for the PSD name (as would be expected), but this occurs at the end of the list of items returned, so this makes it hard to pair things up with
cbind()
. Second,psdAdd()
is returning more items than I expect (i.e., more items than there were rows in the dataframe). The extra items returned only appears to occur if I have anNA
for species and more than one species for the values that are notNA
. This is making it difficult for me to add psd size classes to a dataframe usingmutate()
or creating a list that I thencbind()
to the original as the number of elements does not match. I originally just deleted rows with species=NA, but cannot do that in this new case (CPUE by PSD class rather than calculating PSD values) as I need to track samples where no species were caught (so no legit species name is available) in order to usecomplete()
to add zero catch data in for any PSD size class that was not caught.Here are some trivial examples illustrating the issue: