title: R: From GeoJson to DataFrame?
body: <p>I've a GeoJson file for Peru and it's states (Departamentos in Spanish).</p>
  
  <p>I can plot Peru's states using leaflet, but as the GeoJson file has not all the data I need, I'm thinking of converting it to a data.frame adding the columns of data I need then return it to GeoJson format for plotting.</p>
  
  <p><strong>Data: You can donwload the GeoJson data of Perú from here:</strong></p>
  
  <p>This is the data I'm using and I need to add it a Sales Column with a row for every state ("NOMBDEP" - 24 in total)</p>
  
  <pre><code>library(leaflet)
  library(jsonlite)
  library(dplyr)
  
  
  states &lt;- geojsonio::geojson_read("https://raw.githubusercontent.com/juaneladio/peru-geojson/master/peru_departamental_simple.geojson", what = "sp")
  </code></pre>
  
  <p>I thought of using "jsonlite" package to transform "GeoJson" to a data frame, but getting this error:</p>
  
  <pre><code>library(jsonlite)
  
  states &lt;- fromJSON(states)
  
  Error: Argument 'txt' must be a JSON string, URL or file.
  </code></pre>
  
  <p>I was expecting that after having a data frame I could be able to do something like:</p>
  
  <pre><code>states$sales #sales is a vector with the sales for every department
  
  states &lt;- toJson(states)
  </code></pre>