title: Remove NAs from spatial dataframe
body: <p>I want to remove NAs from &quot;SpatialPolygonsDataFrame&quot;. Traditional df approach and subsetting (mentioned above) does not work here, because it is a different type of a df. I tried to remove NAs as for traditional df and failed. The firsta answer, which also good for traditional df, does not work for spatial.
  I combine csv and a shape file below</p>
  <pre><code>countries &lt;- readOGR(&quot;.&quot;,&quot;ne_50m_admin_0_countries&quot;)
  </code></pre>
  <p>I receive</p>
  <pre><code>class(data_pg_df)
  [1] &quot;SpatialPolygonsDataFrame&quot;
  attr(,&quot;package&quot;)
  [1] &quot;sp&quot;
  </code></pre>
  <p>When I try to create a simple leaflet map, NAs create a problem.</p>
  <pre><code>[1] NA     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA    
  [13] NA     NA     NA     NA     NA     NA     NA     NA     NA     &quot;SSA&quot;  &quot;SSA&quot;  NA    
  [25] NA     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/B3Lia.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B3Lia.jpg" alt="Map" /></a></p>
  <p>I tried to remove NAs with <strong>sp.na.omit()</strong>, but receive an error</p>
  <pre><code>Error in sp.na.omit(data_pg_df) : could not find function &quot;sp.na.omit&quot;
  </code></pre>
  <p>Shape also does not work.
  My goal is remove NAs and have a clean map with polygons</p>
  <p><a href="https://i.stack.imgur.com/bu2oy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bu2oy.jpg" alt="Map 2" /></a></p>
  <p>Thanks!</p>