<div dir="ltr">Hi Ezra,<div><br></div><div>Thanks for your help.  It sounds like implementing this feature will be hard if I reply on making a custom geo.  I&#39;m going to try what you suggest at the end - making the geo with the wildcard, and then removingwhat I don&#39;t need before returning it to the client.</div>
<div><br></div><div>Ari</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 14, 2014 at 12:47 PM, Ezra Haber Glenn <span dir="ltr">&lt;<a href="mailto:eglenn@mit.edu" target="_blank">eglenn@mit.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Ari:<br>
<br>
Good question.  Here are some thoughts on how to approach it:<br>
<br>
Your idea of creating something with geo.make(zip.code= &quot;*&quot;), and then<br>
modifying, if a great idea, but unfortunately it won&#39;t work: the<br>
geo.set that you create with a wildcard is pretty dumb -- it just<br>
contain the wildcard, not all the geographies that it matches to.<br>
<br>
Nonetheless, it&#39;s a good start, and can be used to get those<br>
geographies through a simple acs.fetch.  Try this:<br>
<br>
&gt; my.geos=geo.make(zip.code=&quot;*&quot;)<br>
<br>
# the actual table number doesn&#39;t really matter here<br>
&gt; some.data=acs.fetch(geography=my.geos, table.number=&quot;B01003&quot;)<br>
<br>
Now we have an acs.object, called some.data, that *does* include all<br>
the geographic info we need.  We can view it with<br>
<br>
# careful -- the whole thing is really long;<br>
# let&#39;s just look at the first few rows<br>
&gt; head(geography(some.data))<br>
         NAME zipcodetabulationarea<br>
1 ZCTA5 01001                 01001<br>
2 ZCTA5 01002                 01002<br>
3 ZCTA5 01003                 01003<br>
4 ZCTA5 01005                 01005<br>
5 ZCTA5 01007                 01007<br>
6 ZCTA5 01008                 01008<br>
<br>
We can capture the &quot;zipcodetabulationarea&quot; values and use some subset<br>
of them to make a new geo.make:<br>
<br>
&gt; sample.zips=geo.make(zip.code=sample(geography(some.data)$zipcodetabulationarea, 100))<br>
<br>
Unfortunately, if you try to make a geo.set with *all* of them, you<br>
get that same error you encountered -- it has to do with the way the<br>
function uses nested recursive loops, which may be less-than-ideal in<br>
theory, but in practice is fine.  (I think the upper limit may be<br>
around 700 or 800 items.)  To get around this, you could create your<br>
geo.set in multiple pieces, and then combine them with &quot;geo.set.a +<br>
geo.set.b&quot; of something similar.<br>
<br>
But all that said, I&#39;d warn you that the acs.fetch command is *very*<br>
slow with very large geo.sets -- each one needs to be individually<br>
fetched, and then the results assembled.  (This is one reason why the<br>
limit of geo.set size at creation is not really a big problem from my<br>
point of view.)  Far better is to just use the wildcard and then<br>
*remove* the rows that you don&#39;t want (i.e., select and remove the<br>
ones for Alaska and Hawaii, in this case).  Would that work?<br>
<br>
--Ezra<br>
<div><div class="h5"><br>
At Sun, 13 Apr 2014 13:57:32 -0400, arilamstein wrote:<br>
&gt;<br>
&gt; I am trying to use geo.make to create a geography of all zip codes /<br>
&gt; zctas in the continental US.  This is slightly challenging because the<br>
&gt; documentation to geo.make says that if you specify the zip.code<br>
&gt; parameter then no other geographies can be selected.<br>
&gt;<br>
&gt; My solution is to use the zipcode package to create a list of all<br>
&gt; zipcodes in the continental us, and then pass that to geo.make.<br>
&gt; However, this creates an error:<br>
&gt;<br>
&gt; library(maps) library(zipcode) data(zipcode)<br>
&gt;<br>
&gt; states_continental = setdiff(state.abb, c(&quot;AK&quot;, &quot;HI&quot;))<br>
&gt; states_continental = c(states_continental, &quot;DC&quot;) zips =<br>
&gt; zipcode[zipcode$state %in% states_continental, &quot;zip&quot;]<br>
&gt;<br>
&gt; geo = geo.make(zip.code=zips) Error: evaluation nested too deeply:<br>
&gt; infinite recursion / options(expressions=)?  Error during wrapup:<br>
&gt; evaluation nested too deeply: infinite recursion /<br>
&gt; options(expressions=)?<br>
&gt;<br>
&gt; I tried to step thru the geo.make code but was not sure how it worked.<br>
&gt; I suspect the error is that the zipcode package includes valid zips<br>
&gt; that are not zctas (e.g. zip codes that refer to post offices), and<br>
&gt; that might cause a problem.  But I am wondering if there is a bug in<br>
&gt; the acs code, or if there is a better way to get the result I am<br>
&gt; looking for.<br>
&gt;<br>
&gt; As a workaround, is there an easy way to remove elements from the<br>
&gt; result of geo.make(zip.code= &quot;*&quot;)?  The resulting object is an S4<br>
&gt; object, which I don&#39;t have experience with.  If the result were a<br>
&gt; data.frame I could just use subsetting against the zips variable I<br>
&gt; have above.  But I am not sure how to do the equivalent operation with<br>
&gt; the resulting S4 object.<br>
&gt;<br>
&gt; Thanks.<br>
&gt;<br>
&gt; Ari<br>
&gt;<br>
&gt;<br>
<br>
</div></div>--<br>
Ezra Haber Glenn, AICP<br>
Department of Urban Studies and Planning<br>
Massachusetts Institute of Technology<br>
77 Massachusetts Ave., Room 7-337<br>
Cambridge, MA 02139<br>
<a href="mailto:eglenn@mit.edu">eglenn@mit.edu</a><br>
<a href="http://dusp.mit.edu/faculty/ezra-glenn" target="_blank">http://dusp.mit.edu/faculty/ezra-glenn</a> | <a href="http://eglenn.scripts.mit.edu/citystate/" target="_blank">http://eglenn.scripts.mit.edu/citystate/</a><br>

<a href="tel:617.253.2024" value="+16172532024">617.253.2024</a> (w)<br>
<a href="tel:617.721.7131" value="+16177217131">617.721.7131</a> (c)<br>
</blockquote></div><br></div>