title: R tryCatch skips error in for loop but error statement is not executed
body: <p>the basic data looks like this with 15 columns and many more rows: </p>
  
  <p>X:</p>
  
  <pre><code>    Zeit Boesel Dresden.Nord Dresden.Winckelmannstrasse 
     1 01.01.2011 01:00   2741    9961.169      NA   
     2 01.01.2011 02:00   3462    19144.478     NA   
     3 01.01.2011 03:00   3675    10772.111     NA       
     4 01.01.2011 04:00   4550    5255.695      NA       
  </code></pre>
  
  <p>Y:</p>
  
  <pre><code>    Zeit Boesel Dresden.Nord Dresden.Winckelmannstrasse 
     1 01.01.2011 01:00   274.24  272.76        273.27           
     2 01.01.2011 02:00   273.97  272.44        273.10   
     3 01.01.2011 03:00   274.11  272.42        273.09          
     4 01.01.2011 04:00   273.91  272.08        272.48         
  </code></pre>
  
  <p>I want to conduct cor.test on these dfs for the respective columns and save only the p.values in result.
  Obviously an error occurs in the for loop for the fourth column (only contains NAs).</p>
  
  <pre><code>    result = numeric()
  
      for (i in 2:15)
      {tryCatch(
        {result = append(result, cor.test(x[,i], y[,i], na.action = "na.omit", method = "spearman")$p.value)}, 
          error=function(e) NA)}
  </code></pre>
  
  <p>By using tryCatch the error is skipped and the loop continues, but the error statement NA is not appended to result so that it only contains 13 columns.</p>
  
  <p>Why doesn't it work and how can this problem be solved?</p>