title: dput() sp object in R
body: <p>Is there a practical way to <code>dput()</code> an <code>sp</code> object in R?</p>
  
  <p>When I try to do the following:</p>
  
  <pre><code>data(World, package = "tmap")
  dput(World[1:10, ], file=(tempFile &lt;- tempfile()))
  World2 &lt;- dget(tempFile)
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>&gt; World2 &lt;- dget(tempFile)
  Error in parse(file = file, keep.source = keep.source) : 
    ...\file14f4ee257b1:155:23: unexpected '&lt;'
  154: 9L, 10L, 12L, 14L, 16L, 17L), class = "data.frame")
  155:     , polygons = list(&lt;
                             ^
  </code></pre>
  
  <p>The <code>&lt;</code> is usually followed by <code>S4 object of class structure("Polygons", package = "sp")&gt;</code>, so <code>dput()</code> apparently does not resolve these nested S4 objects.</p>
  
  <p>The problem seems to be quite similar to <a href="https://stackoverflow.com/q/3466599/2114932">this one</a>, but the <a href="https://stackoverflow.com/a/3474049/2114932">proposed solution</a> does not work here.</p>
  
  <p>For a solution, please assume that I do not have access to the file system.</p>
  
  <p>EDIT: The more general question is, of course: How can I send a complete <code>sp</code> object to the console?</p>