Open adamcohen3 opened 1 year ago
I encountered the same issue. For future reference, this is because dplyr feeds the entire vector into the reverse_zipcode()
function, and one of your ZIP codes is invalid. You can add rowwise() %>%
prior to the mutate (and ungroup()
afterwards to avoid weird behavior for subsequent functions), or just use a for loop to go through line by line (if, like me, you need to do additional checks on the reverse_zipcode()
output, for instance that it only returns one value, or a non-NA value, etc.).
When I use reverse_zipcode in a mutate, it throws an error when it encounters a repeat real zipcode (in the example, zip 96817, but notice not for 00000). I was expecting it to do a vectorized operation, but that doesn't seem to be the case. Appreciate any insights people might have.
Error in
mutate()
: ℹ In argument:county = reverse_zipcode(zipcode)$county
. Caused by error: !county
must be size 13 or 1, not 12. Runrlang::last_trace()
to see where the error occurred.