slu-openGIS / postmastr

R package for Processing and Parsing Untidy Street Addresses
https://slu-opengis.github.io/postmastr/
GNU General Public License v3.0
37 stars 8 forks source link

Output option "full" for pm_rebuild() not working #21

Open natalieoshea opened 4 years ago

natalieoshea commented 4 years ago

When the output argument for pm_rebuild() is set to "full" you receive the error message Error: object 'endQ' not found

library(tidyverse)
library(postmastr)

dirs <- pm_dictionary(type = "directional", filter = c("N", "S", "E", "W"), locale = "us")

original_df <- postmastr::sushi2 %>%
  pm_identify(var = address) 

parsed_df <- original_df %>%
  pm_prep(var = "address", type = "street") %>%
  pm_house_parse() %>%
  pm_streetDir_parse(dictionary = dirs) %>%
  pm_streetSuf_parse() %>%
  pm_street_parse(ordinal = TRUE, drop = TRUE)

merged_df <- pm_replace(parsed_df, source = original_df)

final_df_short <- pm_rebuild(merged_df, "short", keep_parsed = "no")
final_df_full <- pm_rebuild(merged_df, "full", keep_parsed = "no") # Error: object 'endQ' not found

Desktop:

SRKadam1 commented 3 years ago

I also had this issue, but with the argument "short". My solution was to manually set endQ in the global environment using endQ <- rlang::quo(!! rlang::sym("pm.sufDir")). In your case, maybe try

endQ <- rlang::quo(!! rlang::sym("pm.sufDir")) # optional, I think
final_df_short <- pm_rebuild(merged_df, "short", keep_parsed = "no"))
endQ <- rlang::quo(!! rlang::sym("pm.zip4") # will hopefully fix error
final_df_full <- pm_rebuild(merged_df, "full", keep_parsed = "no")

I wasn't able to figure out why this error gets thrown. Hope this workaround is useful for you.