text: user4595: I have a dataframe like this
  > dim(anno_maf)
  [1] 32786   129
  > head(anno_maf[1:2,1:4])
     Tumor_Sample_Barcode Chromosome Start_Position
  1:                    a       chr1       27105930
  2:                    a       chr1        3342771
     End_Position
  1:     27105930
  2:      3342771
  > 
  
  I have a list of genes like
  gene name
  PTEN
  PTEN
  MAP3K1
  MALAT1
  MED12
  RUNX1
  PIK3CA
  FBXW7
  ARID1A
  MED12
  TAB1
  
  I want to add a column in my dataframe named COSMIC, if a gene in gene list exists in my dataframe Hugo_Symbol column, put a yes for this gene if not put a no; Finally my data frame has an extra column as COSMIC in which I have yes or no in Hugo_Symbol column based on the existence of genes in my gene list
  Can you help me please?
  Thank you
  
  user3541: You can use ifelse():
  anno_maf$COSMIC <- ifelse(anno_maf$Hugo_Symbol %in% your_gene_list,
                            yes = "yes",
                            no = "no")
  
  
original_text: 4595: <p>I have a dataframe like this</p>
  
  <pre><code>&gt; dim(anno_maf)
  [1] 32786   129
  &gt; head(anno_maf[1:2,1:4])
     Tumor_Sample_Barcode Chromosome Start_Position
  1:                    a       chr1       27105930
  2:                    a       chr1        3342771
     End_Position
  1:     27105930
  2:      3342771
  &gt; 
  </code></pre>
  
  <p>I have a list of genes like</p>
  
  <pre><code>gene name
  PTEN
  PTEN
  MAP3K1
  MALAT1
  MED12
  RUNX1
  PIK3CA
  FBXW7
  ARID1A
  MED12
  TAB1
  </code></pre>
  
  <p>I want to add a column in my dataframe named COSMIC, if a gene in gene list exists in my dataframe <strong><em>Hugo_Symbol</em></strong> column, put a <strong>yes</strong> for this gene if not put a <strong><em>no</em></strong>; Finally my data frame has an extra column as <strong><em>COSMIC</em></strong> in which I have <strong><em>yes</em></strong> or <strong><em>no</em></strong> in <strong><em>Hugo_Symbol</em></strong> column based on the existence of genes in my gene list</p>
  
  <p>Can you help me please?</p>
  
  <p>Thank you</p>
   3541: <p>You can use <code>ifelse()</code>:</p>
  
  <pre><code>anno_maf<span class="math-container">$COSMIC &lt;- ifelse(anno_maf$</span>Hugo_Symbol %in% your_gene_list,
                            yes = "yes",
                            no = "no")
  </code></pre>
  