title: How to Subset more than Once in a Data Frame in R?
body: <p>I have the following Data Set.</p>
  <pre><code>&gt; eh
     PEG AEG
  1    1   1
  2    1   0
  3    1   1
  4    1   1
  5    0   0
  6    0   0
  7    1   1
  8    1   1
  9    0   0
  10   0   1
  11   1   1
  12   0   0
  13   0   0
  14   0   0
  15   0   0
  16   1   1
  17   1   0
  18   1   1
  19   0   0
  20   0   0
  21   0   0
  22   0   0
  23   0   0
  24   1   1
  25   1   0
  26   0   1
  27   0   0
  28   1   1
  29   0   0
  30   1   1
  31   0   0
  32   0   0
  33   1   1
  34   1   1
  35   0   0
  36   0   1
  37   1   1
  38   1   0
  39   1   1
  40   1   1
  41   1   0
  42   0   0
  43   0   1
  </code></pre>
  <p>I am trying to find all of the columns in which both PEG and AEG equal one, and count the number of instances there are.</p>
  <p>I understand I am close, and its probably me overlooking and not understanding the syntax since I am a beginner in R, but have tried the following code.</p>
  <pre><code>eh[which(eh$PEG == 1,) &amp; (eh$AEG == 1,)]
  
  </code></pre>
  <p>Could anyone tell me What is wrong with the code here, and how once I do this, I could count the number of instances there?</p>