title: R How to count occurrences of values across multiple columns of a data frame and save the columnwise counts from a particular value as a new row?
body: <p>I have a large data-frame (approx 1,000 rows and 30,000 columns) that looks like this:</p>
  
  <pre><code>   chr pos  sample1 sample2 sample3 sample 4
      1 5050    1       NA      0       0.5
      1 6300    1       0       0.5     1
      1 7825    1       0       0.5     1
      1 8200    0.5     0.5     0       1
  </code></pre>
  
  <p>where at a given "chr"&amp;"pos" the value for a given sample can take the form of 0, 0.5, 1, or NA. I have a large number of queries to perform that will require subsetting and ordering the data frame based on summaries of the values for each sample.</p>
  
  <p>I would like to get a count of the number of occurrences of a given value (e.g. 0.5) for each column, and save that as a new row in my data frame. My ultimate goal is to be able to use the values of the new row to subset and/or order the columns of my data frame. I've seen similar questions about counting occurrences, but I can't seem to find/recognize a solution to doing this across all columns simultaneously and saving the column-wise counts for a particular value as a new row.</p>