title: How to find the percentage of NAs in a data.frame?
body: <p>I am trying to find the percentage of NAs in columns as well as inside the whole dataframe:</p>
  
  <p>The first method which I have commented gives me zero and the second method which is not commented gives me a matrix. Not sure what I am missing. Any hint is truly appreciated!</p>
  
  <pre><code>cp.2006&lt;-read.csv(file="cp2006.csv",head=TRUE)
  
  #countNAs &lt;- function(x) { 
  #  sum(is.na(x)) 
  #} 
  #total=0
  #for (i in col(cp.2006)) {
  #  total=countNAs(i)+total
  #}
  #print(total)
  count&lt;-apply(cp.2006, 1, function(x) sum(is.na(x)))
  dims&lt;-dim(cp.2006)
  num&lt;-dims[1]*dims[2]
  NApercentage&lt;-(count/num) * 100
  print(NApercentage)
  </code></pre>