Finding columns in dataframe with specific number of values in R : <p>I have a dataframe(data.table) with over 3000 columns. I need to find out the columns in my dataframe that have only 2 and less than 2 values in them. I then after extracting those columns with 2 and less then 2 values I want to drop them out of the original data frame. 
I illustrate as follows:
Original data frame</p>

<pre><code>Month   A       B         C
Jan-00  0.007   NA       1758.27
Feb-00  0.004   NA       1310.43
Mar-00  0.004   NA       1260.89
Apr-00  0.004   0.0002   1137.34
May-00  0.005   6.05E-05 1595.78
Jun-00  0.003   NA       4968.89
Jul-00  0.007   NA       NA
Aug-00  0.005   NA       NA
Sep-00  0.004   NA       NA
</code></pre>

<p>Desired output</p>

<pre><code>     Month    A         C
    Jan-00  0.007   1758.27
    Feb-00  0.004   1310.435
    Mar-00  0.004   1260.89
    Apr-00  0.004   1137.342105
    May-00  0.005   1595.78125
    Jun-00  0.003   4968.895238
    Jul-00  0.007   NA
    Aug-00  0.005   NA
    Sep-00  0.004   NA
</code></pre>

<p>I would appreciate your help in this regard.</p>
