Skip to content

weird behavior when using reverse_zipcode inside a mutate #27

@adamcohen3

Description

@adamcohen3

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.

library(dplyr)
library(zipcodeR)
df <- data.frame(id = 1:13,
                 zipcode = c("96753", "00000", "96744", "96782", "00000", "96720", "96813", "96712", "96817", "96818", "96822", "00000", "96817"))
df2 <- df %>% 
  mutate(county = reverse_zipcode(zipcode)$county)

Error in mutate():
ℹ In argument: county = reverse_zipcode(zipcode)$county.
Caused by error:
! county must be size 13 or 1, not 12.
Run rlang::last_trace() to see where the error occurred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions