title: Trouble with if-statement using any( ) and apply( )
body: <p>Suppose that I have the following table of information:</p>
  
  <pre><code>firstname &lt;- c('Todd','Sven','Robert','Jovan','Angelo')
  city &lt;- c('Edmond', NA ,'Miami','Houston', NA)
  state &lt;- c('OK','KS', NA, 'TX', NA)
  job &lt;- c('Clown','Plumber','Professor', 'Uber Driver', 'Therapist')
  
  list_test &lt;- data.frame(firstname, city, state, job)
  list_test
  
    firstname    city state         job
  1      Todd  Edmond    OK       Clown
  2      Sven    &lt;NA&gt;    KS     Plumber
  3    Robert   Miami  &lt;NA&gt;   Professor
  4     Jovan Houston    TX Uber Driver
  5    Angelo    &lt;NA&gt;  &lt;NA&gt;   Therapist
  </code></pre>
  
  <p>I want to return a message if any of the columns is NA, which can be identified by doing this:</p>
  
  <pre><code>any(apply(list_test, 2, function(x){any(is.na(x))}))
  [1] TRUE
  </code></pre>
  
  <p>My thought is to create a simple if-return statement like below.</p>
  
  <pre><code>if(any(apply(list_test, 2, function(x){any(is.na(x))}))) {
    return("At least one row has an NA value.")
  }
  </code></pre>
  
  <p>However, I get the following error message:</p>
  
  <pre><code>Error: no function to return from, jumping to top level
  </code></pre>
  
  <p>I am confused as to why I am getting this error message.</p>
  
  <p>Thank you!</p>