title: How to group variables and do barplot in R?
body: <p>I want to compare the counts or relative frequencies of the variables using R barplot.</p>
  
  <p>This is a sample dataframe</p>
  
  <pre><code>       Q7B1 Q7A2 Q7B2 Q7A3 Q7B3
      1    NA    2   NA    1    2
      2    NA    2   NA    1    2
      3     2    2   NA    1    2
      4     2    2   NA    1    2
      5    NA    2   NA    1    2
      6    NA    2   NA    2   NA
      7     2    2   NA    1    2
      8    NA    2   NA    2   NA
      9    NA    2   NA    2   NA
      10    2    2   NA    1    2
  </code></pre>
  
  <p>I would like to create a barplot where each variable (Q7B1, Q7B2, Q7B3, ....,Q7B8) represents a bar. Each variable has values (1,2,3) The height of the bar would represent the count or the relative frequency of the value "2" of each variable. How do I do this in R?</p>