title: Leaflet map 'Error in polygonData.default(data) : Don't know how to get path data from object of class data.frame'
body: <p>I'm trying to create a leaflet map of census data.</p>
  <p>I have a csv file contains the number of deaths across Ireland. The data consists of the year($Year), the Sex ($Sex), the location($NAME_1) and the age at death ($Age.at.Death)</p>
  <p>Likewise I have a dbf file that contains the location ($NAME_1) and the geometry needed for polygons to create the map.</p>
  <p>All of the data merges correctly into DEATHS1, but as soon as I pass this to leaflet I get the error
  'Error in polygonData.default(data) :
  Don't know how to get path data from object of class data.frame'</p>
  <pre><code>library(leaflet)
  library(sf)
  library(dplyr)
  
  DEATHS &lt;- read.csv(&quot;VSA07.csv&quot;)
  
  Shape &lt;- read_sf(&quot;gadm36_IRL_1.dbf&quot;)
  
  
  MergedData = inner_join(DEATHS,Shape) #inner joins by NAME_1 column, works okay.
  
  DEATHS1 &lt;- filter(MergedData, Year == &quot;2007&quot;, Age.at.Death == &quot;All ages&quot;, Sex == &quot;Both sexes&quot;)
  # Want a map satisfying the above conditions only for the moment, also works as intended
  
  DEATHS1
  
  
  bins &lt;- c(0, 500, 1000, 2000, 3000, 4000, Inf)
  pal &lt;- colorBin(&quot;YlOrRd&quot;, domain = DEATHS1$VALUE, bins = bins)
  
  
  m &lt;-leaflet() %&gt;%
    addProviderTiles(providers$Stamen.TonerHybrid) %&gt;% 
    addPolygons(data = DEATHS1)
  m
  
  </code></pre>
  <p>The strange thing is that leaflet can plot a map based on MergedData
  but as soon as I apply any kind of filters through dplyr, ie DEATHS1, I get the error.
  So I don't think its anything to do with it being a data frame as MergedData is exactly that.</p>
  <p>Any help is greatly appreciated.</p>
  <p>A snapshot of the data
  DEATHS</p>
  <pre><code>     ï..Statistic Year      NAME_1        Sex      Age.at.Death   UNIT VALUE
  1   Deaths Occurring 2007       State Both sexes      Under 1 year Number   230
  2   Deaths Occurring 2007       State Both sexes       1 - 4 years Number    54
  </code></pre>
  <p>Shape</p>
  <pre><code>A tibble: 26 x 11
     GID_0 NAME_0  GID_1  NAME_1  VARNAME_1     NL_NAME_1 TYPE_1     ENGTYPE_1 CC_1  HASC_1                                    geometry
     &lt;chr&gt; &lt;chr&gt;   &lt;chr&gt;  &lt;chr&gt;   &lt;chr&gt;         &lt;chr&gt;     &lt;chr&gt;      &lt;chr&gt;     &lt;chr&gt; &lt;chr&gt;                           &lt;MULTIPOLYGON [°]&gt;
   1 IRL   Ireland IRL.1~ Carlow  Ceatharlach   NA        Administr~ County    NA    IE.CW  (((-6.592422 52.7081, -6.592915 52.7073, -~
   2 IRL   Ireland IRL.2~ Cavan   An Cabhán     NA        Administr~ County    NA    IE.CN  (((-7.275174 53.78388, -7.275377 53.78377,~
   3 IRL   Ireland IRL.3~ Clare   An Clár       NA        Administr~ County    NA    IE.CE  (((-9.731943 52.64875, -9.731943 52.64903,~
  </code></pre>
  <p>DEATHS1</p>
  <pre><code>       ï..Statistic Year    NAME_1        Sex Age.at.Death   UNIT VALUE GID_0  NAME_0    GID_1              VARNAME_1 NL_NAME_1            TYPE_1 ENGTYPE_1 CC_1 HASC_1                       geometry
  1  Deaths Occurring 2007   Wicklow Both sexes     All ages Number   819   IRL Ireland IRL.26_1  Administrative County    County &lt;NA&gt;  IE.WW MULTIPOLYGON (((-6.109166 5...
  </code></pre>
  <p>Any help is much appreciated/</p>