title: Replace geometries from a list in sf
body: <p>Suppose I have the following <code>sf</code> data frame:</p>
  
  <pre><code>library(sf)
  
  nrows &lt;- 10
  geometry = st_sfc(lapply(1:nrows, function(x) st_geometrycollection()))
  df &lt;- st_sf(id = 1:nrows, geometry = geometry)
  </code></pre>
  
  <p>And I also have the following list:</p>
  
  <pre><code>mylist = list('2'=st_point(c(-73,42)), '3'=NA) 
  </code></pre>
  
  <p>I want to replace the geometry from the second observation with the point in the list.  I had thought about doing the following:</p>
  
  <pre><code>st_geometry(df[names(mylist),]) &lt;- st_sfc(mylist)
  </code></pre>
  
  <p>But this throws an error:</p>
  
  <blockquote>
    <p>"Error in vapply(lst, class, rep(NA_character_, 3)) :    values must
    be length 3,  but FUN(X[[2]]) result is length 1"</p>
  </blockquote>
  
  <p>I found the following workaround by first eliminating the NA values:</p>
  
  <pre><code>condition &lt;- mylist[!is.na(mylist)]
  st_geometry(df[names(condition),]) &lt;- st_sfc(condition)
  </code></pre>
  
  <p>Is there a better way to do this? Can I force the NA elements in <code>mylist</code> to be empty points?</p>