title: R count number of specific string in data frame
body: <p>Sorry for beginner questions.</p>
  
  <p>I have a data frame(I think, please correct me if I'm wrong here.)</p>
  
  <pre><code>data &lt;- read.csv("adult.data", sep=',', header=F)
  </code></pre>
  
  <p>Data is <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data" rel="nofollow">https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data</a></p>
  
  <p>When data is missing, it just has "?" instead of data. I need to count how much data is missing in each column.</p>
  
  <p>I can count instances of a number, but not strings.</p>
  
  <p>Col 1 is age, so I can do this:</p>
  
  <pre><code>length(which(data[,1] == 55))
  </code></pre>
  
  <p>And it will tell me how many people were 55 in this dataset.</p>
  
  <p>But if I try </p>
  
  <pre><code>length(which(data[,2] == "?"))
  </code></pre>
  
  <p>It says 0.</p>
  
  <p>How do I compare strings in R?</p>