"Unused Argument" Error in censusxy package

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##
#> The downloaded binary packages are in
#>  /var/folders/dk/d3fzp_nj3qx_vwyz9gyw8hqm0000gn/T//RtmpVbn7VJ/downloaded_packages
library (censusxy)

###Check available 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###
#> 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?

Thanks in advance for any help.


Checking the help information by typing the following information in the R console

? cxy_geocode

you (probably **) see that the function can handle the following arguments (but not address) :

cxy_geocode <- function(.data, id = NULL, street, city = NULL, state = NULL, 
zip = NULL, return = 'locations', benchmark = 'Public_AR_Current', vintage = NULL, 
timeout = 30, parallel = 1, class = 'dataframe', output = 'simple')  

(**) I get this information from GitHub (because I have not installed the package on my machine) but I expect it to be equal to your help info.

In the same GitHub repository I see that cxy_benchmarks has no arguments at all.
You could verify this with

? cxy_benchmarks

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:


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

Created on 2020-07-16 by the reprex package (v0.3.0)

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.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.