title: How to subset the rows of my data frame based on a list of names?
body: <p>I have a gene expression count data set with 2 columns and ~60000 rows. Each column is a sample and each row is a gene represented by an ensembl ID. I need to reduce or subset by data to include only genes that are protein coding. Here is a small scale example of what I would like to achieve:</p>
  <p>Here is my data set called <code>BDC</code> containing the ensembl ID's of various types of genes along with the count data for each sample:</p>
  <pre><code>ENSEMBL           Sample A    Sample B
  ENSG00000198888      10          2
  ENSG00000210082      3           13
  ENSG00000198763      6           18
  ENSG00000198886      12          11
  </code></pre>
  <p>I also have a list of ensembl ID's called <code>ProtCod</code> that contain genes that I know are protein coding:</p>
  <pre><code>ENSEMBL_Protein_Coding
  ENSG00000198888
  ENSG00000198763
  </code></pre>
  <p>So I want to subset my data set to only include rows that have a protein coding ensembl ID and exclude all other rows:</p>
  <pre><code>ENSEMBL           Sample A    Sample B
  ENSG00000198888      10          2
  ENSG00000198763      6           18
  </code></pre>
  <p>But I need to achieve this on the large scale reducing my data set from ~60000 to ~20000 rows or genes.</p>
  <p>This is what I've tried so far:</p>
  <pre><code>BDCProtCod &lt;- BDC[!row.names(BDC) %in% ProtCod, ]
  BDCProtCod
  dim(BDCProtCod)
  [1] 60675 2
  </code></pre>
  <p>The dimensions are the same as my original <code>BDC</code> data set, why isn't this code excluding the rows that don't contain names from <code>ProtCod</code>?</p>
  <p>I've also tried:</p>
  <pre><code>BDCProtCod &lt;- BDC[unlist(ProtCod), ]
  BDCProtCod
  dim(BDCProtCod)
  [1] 19603 2
  </code></pre>
  <p>This actually excludes the rows I want to be excluded but it sets everything to &quot;NA&quot;.</p>