Relatively new to R and trying to use the new "censusxy" package to attach a batch of ~280K addresses to their relevant census tract geography. See reprex below.
###Load in Census XY##
install.packages("censusxy")
#>
#> The downloaded binary packages are in
#> /var/folders/dk/d3fzp_nj3qx_vwyz9gyw8hqm0000gn/T//RtmpVbn7VJ/downloaded_packages
library (censusxy)
###Check available benchmarks###
cxy_benchmarks()
#> id benchmarkName benchmarkDescription
#> 2 4 Public_AR_Current Public Address Ranges - Current Benchmark
#> 21 8 Public_AR_ACS2019 Public Address Ranges - ACS2019 Benchmark
#> 3 9 Public_AR_Census2010 Public Address Ranges - Census 2010 Benchmark
#> isDefault
#> 2 FALSE
#> 21 FALSE
#> 3 FALSE
###Run Geocoding###
cxy_benchmarks(9)
#> Error in cxy_benchmarks(9): unused argument (9)
cxy_vintages(benchmark = 9)
#> id vintageName vintageDescription
#> 2 910 Census2010_Census2010 Census2010 Vintage - Census2010 Benchmark
#> 21 900 Census2000_Census2010 Census2000 Vintage - Census2010 Benchmark
#> isDefault
#> 2 TRUE
#> 21 FALSE
addr_msa_gc <- cxy_geocode(addr_msa, address = addr, city = city, state = state, zip = ZCTA5, class = "dataframe")
#> Error in cxy_geocode(addr_msa, address = addr, city = city, state = state, : unused argument (address = addr)
Has anyone run into this issue before and is there an issue in the code causing this unused argument error?
Hi and welcome, @aharrison. As @HanOostdijk pointed out, you need street = "addr" in cxy_geocode(). In addition, the column names must be quoted. See below for an example:
library(censusxy)
df <- data.frame(
address = "261 Moore Street",
city = "Brooklyn",
state = "NY",
zip = "11211"
)
cxy_geocode(df, street = "address", city = "city", state = "state", zip = "zip")
#> Loading required namespace: sf
#> address city state zip cxy_lon cxy_lat
#> 1 261 Moore Street Brooklyn NY 11211 -73.93432 40.70477
But, a larger point to consider, is that the census geocoding API is not very fast and I doubt you will be able to successfully geocode 280k addresses. You certainly won't be able to do it in a single call and will need to break up the input addresses into chunks. If you really need to geocode all these address, there may be a better solution for this large of a batch.