title: TryCatch warning inside 2 lapply
body: <p>I've got the following code:</p>
  <pre><code>fit.list &lt;- lapply(sample.names, function(sample.name) {
      lapply(f1(target), function(seq.name) {
          f2(arguments)
      })
  })
  </code></pre>
  <p>f2 is returning sometimes:</p>
  <pre><code>warning(&quot;Warning message&quot;)
  return(NULL)
  </code></pre>
  <p>How can I catch the warning message inside the second lapply? I'm a newbie to R, excuse me.</p>
  <p>EDITED:</p>
  <p>Could be one of these workarounds?</p>
  <p>1</p>
  <pre><code>tryCatch({
          fit.list &lt;- lapply(sample.names, function(sample.name) {
              print(sample.name);
              lapply(f1(target), function(seq.name) {
                  f2(arguments)
              })
          })
      }, 
      warning=function(e) {
              message(paste(&quot;Warning caused by sample:&quot;, sample))
              return(NULL)
          })
  </code></pre>
  <p>2</p>
  <pre><code>fit.list &lt;- lapply(sample.names, function(sample.name) {
      
      tryCatch({
          lapply(f1(target), function(seq.name) {
              f2(arguments)
          })
      }, 
      warning=function(e) {
              message(paste(&quot;Warning caused by sample:&quot;, sample))
              return(NULL)
          })
  })
  </code></pre>
  <p>3</p>
  <pre><code>fit.list &lt;- lapply(sample.names, function(sample.name) {
  
      lapply(f1(target), function(seq.name) {
      
          tryCatch({
              f2(arguments)
          }, 
          warning=function(e) {
              message(paste(&quot;Warning caused by sample:&quot;, sample))
              return(NULL)
          })  
      })
  })
  </code></pre>
  <p>Thank you very much!</p>