pfmc-assessments / PacFIN.Utilities

R code to manipulate data from the PacFIN database for assessments
http://pfmc-assessments.github.io/PacFIN.Utilities
Other
7 stars 1 forks source link

getAge grep fails when missing age1 #54

Closed chantelwetzel-noaa closed 3 years ago

chantelwetzel-noaa commented 3 years ago

https://github.com/nwfsc-assess/PacFIN.Utilities/blob/3d78354a3a65561d1b262026323af2ab87fcf3a3/R/getAge.R#L71

In a new bds pull my species has only age2, no age1. The getAges function fails in this situation. If I add in an age1 column to the data frame prior to calling this function the error goes away. Need to update the grep to handle the above situation which should be an easy fix.

kellijohnson-NOAA commented 3 years ago

Thanks @chantelwetzel-noaa for noticing this. I am torn if we should go forward with age1, age2, ... or age, age2, age3. I think that the latter is more clear, though I am changing the code to accommodate either. I will leave this open for a few more days in case people want the data frame to use one or the other.

chantelwetzel-noaa commented 3 years ago

I prefer the latter approach as well. I think it makes things a bit clearer. Depending upon what everyone else thinks, I think the key is to just make the age column checking a bit more robust to deal with any combination of age column numbering.