title: Checking if date is blank in R?
body: <p>An easy one but I am sure someone knows how to do this...</p>
  
  <p>In R, I was looking for something like <em>is.blank</em> to error trap in my function where a User can specify a date <strong>or it can be blank</strong> and we will default to use Today's date (i.e. <code>Sys.Date()</code>)</p>
  
  <p>I tried</p>
  
  <pre><code>date.end &lt;- ""
  
  # then in function  
  if (date.end == "" || is.null(date.end)) {
    message("end date not specified and so setting to today")
    date.end &lt;- Sys.Date()
  } else {
    # use the date.end passed in as Date class
  }
  </code></pre>
  
  <p>But this check freaks out charToDate(), i.e. </p>
  
  <pre><code>test.end == ""
  Error in charToDate(x) : 
    character string is not in a standard unambiguous format
  </code></pre>
  
  <p>Please advise <strong>how does one check for blank dates in base R?</strong>
  (And any other wisdom for error trapping dates...)</p>
  
  <p><em>Adding to clarify:</em></p>
  
  <ol>
  <li><p>Most times the function will get good dates, e.g.</p>
  
  <pre><code>date.end &lt;-  as.Date("31/03/2015", "%d/%m/%Y")
  </code></pre>
  
  <p>So I do not want to change class.</p></li>
  <li><p>However, how do you handle the odd case where you want to default to today if user does not specify a date?  </p></li>
  </ol>