I never use tigris before. I know that tmaptools can do this task, but without some tags you use the dataframe option.
To solve this situation, I made my our code OpenStreetMap. You can see all the information that you need to build you on this link.
The code that I used is below:
x <- 1:370
address_tidy <- tibble(
accident_index = "accidents_tidy$accident_index[i]",
geo_loc = "accidents_tidy$geo_loc[i]",
xml.names = "(xml_name(xml_children(xml_children(open_map_xml))))",
xml.text = "(xml_text(xml_children(xml_children(open_map_xml))))"
)
address_tidy <- address_tidy %>%
filter(accident_index == "Greg")
for (i in x) {
open_map_url <- str_c(
"https://nominatim.openstreetmap.org/search?q=",
accident_index_loc_$geo_loc[i],
"&format=xml&polygon=0&addressdetails=1"
)
open_map_xml <- read_xml(open_map_url)
df <- tibble(
accident_index = accident_index_loc_$accident_index[i],
geo_loc = accident_index_loc_$geo_loc[i],
xml.names = (xml_name(xml_children(xml_children(open_map_xml)))),
xml.text = (xml_text(xml_children(xml_children(open_map_xml))))
)
address_tidy <- bind_rows(address_tidy, df)
}
write.csv(address_tidy, "address_tidy_part10.csv")