[acs-r] Getting all zipcodes in the continental US

arilamstein@gmail.com arilamstein at gmail.com
Sun Apr 13 13:57:32 EDT 2014


I am trying to use geo.make to create a geography of all zip codes / zctas
in the continental US.  This is slightly challenging because the
documentation to geo.make says that if you specify the zip.code parameter
then no other geographies can be selected.

My solution is to use the zipcode package to create a list of all zipcodes
in the continental us, and then pass that to geo.make.  However, this
creates an error:

library(maps)
library(zipcode)
data(zipcode)

states_continental = setdiff(state.abb, c("AK", "HI"))
states_continental = c(states_continental, "DC")
zips = zipcode[zipcode$state %in% states_continental, "zip"]

geo = geo.make(zip.code=zips)
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
Error during wrapup: evaluation nested too deeply: infinite recursion /
options(expressions=)?

I tried to step thru the geo.make code but was not sure how it worked.  I
suspect the error is that the zipcode package includes valid zips that are
not zctas (e.g. zip codes that refer to post offices), and that might cause
a problem.  But I am wondering if there is a bug in the acs code, or if
there is a better way to get the result I am looking for.

As a workaround, is there an easy way to remove elements from the result of
geo.make(zip.code="*")?  The resulting object is an S4 object, which I
don't have experience with.  If the result were a data.frame I could just
use subsetting against the zips variable I have above.  But I am not sure
how to do the equivalent operation with the resulting S4 object.

Thanks.

Ari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/acs-r/attachments/20140413/1866ef17/attachment.htm


More information about the acs-r mailing list