title: TopoJSON choropleth in R/Leaflet?
body: <p>Is it possible to style a TopoJSON file from its features for a choropleth using R/leaflet? Tried a few things, and I'm not sure if this is impossible with the <code>leaflet</code> package or if I just don't have the syntax right, especially accessing the properties to enter in the <code>pal()</code> function. Here's what I have:</p>
  
  <pre><code>pal&lt;-colorNumeric(palette ="YlOrRd",domain = USAdata$GINI) #USAdata data frame I merged with the spdf before converting it to shp/topojson
  
  map&lt;-leaflet() %&gt;% 
    addTiles(options=tileOptions(minZoom = 3)) %&gt;% 
    setMaxBounds(-167.276413,5.499550,-52.233040, 83.162102) %&gt;%
    setView(93.85,37.45,zoom =3) %&gt;%
    #addGeoJSON(geojson = jso5)
    addTopoJSON(topojson=jso, fillColor = ~pal("GINI"))
  #addPolygons(data=poly)
  </code></pre>
  
  <p>this throws up an error: </p>
  
  <pre><code>"Error in UseMethod("doResolveFormula") : 
    no applicable method for 'doResolveFormula' applied to an object of class "NULL""
  </code></pre>
  
  <p>I also tried converting it to an R object the topojson with fromJSON() and adding style elements, but this won't load after I try send it back with toJSON().</p>
  
  <p>Not sure if relevant, but the topojson was created from a shapefile made following the instructions <a href="https://stackoverflow.com/questions/26357580/how-to-combine-state-level-shapefiles-from-the-united-states-census-bureau-into">here</a>: </p>
  
  <p>with cl:</p>
  
  <pre><code>topojson -o 'USApuma.json' --shapefile-encoding utf8 --id-property=+GEOID10 -p GINI,+STATEFP10,+GEOID10 -- 'usaetest.shp'
  </code></pre>
  
  <p>then read in with <code>readLines()</code>. </p>
  
  <p>Eventually trying to throw this into a shiny app. Here's <a href="https://rstudio.github.io/leaflet/colors.html" rel="nofollow">some</a> examples I've been <a href="http://zevross.com/blog/2015/10/14/manipulating-and-mapping-us-census-data-in-r-using-the-acs-tigris-and-leaflet-packages-3/#make-your-map-leaflet" rel="nofollow">following</a>.</p>