title: How to handle NAs in correlation output in spite of "pairwise.complete.obs"
body: <p>I'm trying to calculate correlation of a variable (g) with the remaining variables in a scale. It shows up NA for a specific group of variables. (s1, s2, s3...)</p>
  
  <p>The values in the variables look like this:</p>
  
  <pre><code>g  = c(1, NA, 4, NA, 3, NA, 3, NA, NA, NA)  
  s1 = c(NA, 3, NA, 2, NA, 3, NA, 4, 4, NA)
  s2 = c(NA, 3, NA, 2, NA, 1, NA, 1, 4, NA)
  s3 = c(NA, 2, NA, 2, NA, 4, NA, 2, 5, NA)
  </code></pre>
  
  <p>It shows correlation to other variables in the scale. 
  Example of those variables:</p>
  
  <pre><code>as1 = c(4, NA, 4, NA, 3, NA, 3, NA, NA, NA)
  ag1 = c(1, NA, 4, NA, 3, NA, 3, NA, NA, NA)
  </code></pre>
  
  <p>I've used the following code: data set "dn"</p>
  
  <pre><code>x &lt;- dn["g"]
  y &lt;- dn[1:20] # all variables
  
  cor(y,x, use="pairwise.complete.obs")
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>var_name           g
  ag1                0.66254379
  ag2               -0.76100601
  ag3                0.76110091
  s1                 NA
  s2                 NA
  s3                 NA
  s4                 NA
  s5                 NA
  as1                0.65019200
  as2                0.45664999
  as3               -0.33246108
  </code></pre>
  
  <p>I also tried "everything", "all.obs", "na.or.complete" and "complete.obs" instead of "pairwise.complete.obs"</p>
  
  <p>I have not been able to figure out why these NAs are appearing. I've been checking for other possible errors in my code, with no luck so far. While I continue to try, is there any other way I can make r calculate the correlation in spite of the NAs? </p>
  
  <p>Note: All values are numeric</p>