title: What is the difference between NULL and character(0) in R?
body: <p>What is the difference between NULL and character(0) | integer(0) etc?</p>
  
  <pre><code>&gt; identical(NULL, character(0))
  [1] FALSE
  
  &gt; is.null(integer(0))
  [1] FALSE
  
  &gt; str(character(0))
   chr(0) 
  
  &gt; str(NULL)
   NULL
  </code></pre>
  
  <p>In general it seems you can pass <code>NULL</code> as parameters into functions, and that an empty vector is generally returned as <code>character(0)</code>, <code>integer(0)</code>, etc.</p>
  
  <p>Why is this the case?  Come to think of it, is there a test for zero-ness, <em>a la</em> <code>is.integer0</code>?</p>