title: How to compute a running cor.test() in a data.frame with NA values in R?
body: <p>I'm trying to do a <strong>running()</strong> correlation between my daily climate data, and the problem is that I have many missing values (NA) in my data.frame. I'm using the <strong>cor.test()</strong> because I need to get the <strong><em>p.values</em></strong>. For example in some days I don't have precipitation or humidity values, and I would like to know how to compute this running correlation with my temperature data, but omitting the NA values.</p>
  
  <p>Here an example with NA values:</p>
  
  <pre><code>library(gtools)
  df &lt;- data.frame(temp=rnorm(100, 10:30), prec=rnorm(100, 1:300), humi=rnorm(100, 1:100))
  
  df$prec[c(1:10, 25:30, 95:100)] &lt;-NA
  df$humi[c(15:19, 20:25, 80:90)] &lt;-NA
  
  corPREC &lt;- t(running(df$temp, df$prec, fun = cor.test, width=10, by=10))
  corHUMI &lt;- t(running(df$temp, df$humi, fun = cor.test, width=10, by=10))
  </code></pre>