title: What is the difference between as.character() and as( ,"character") in R
body: <p>In the surface they both seem to be doing the same thing. But it seems to be the case that the latter <code>as(,"character")</code> is more powerful. </p>
  
  <p>As an example consider the following:</p>
  
  <pre><code>library(rvest)
  
  temp &lt;- html("http://www.example.com/")
  temp &lt;- temp %&gt;% html_node("div p")
  
  str(temp)
  #Classes 'XMLInternalElementNode', 'XMLInternalNode', 'XMLAbstractNode' &lt;externalptr&gt; 
  
  as.character(temp) 
  #Error in as.vector(x, "character") 
  #   cannot coerce type 'externalptr' to vector of type 'character'
  </code></pre>
  
  <p>Whereas <code>as(temp, "character")</code> gives</p>
  
  <pre><code>#[1] "&lt;p&gt;This domain is established to be used for illustrative examples in documents. You may use this\n    domain in examples without prior coordination or asking for permission.&lt;/p&gt;"
  </code></pre>