text: user4595: I have a too big data frame
  > dim(anno_maf)
  [1] 2635299     132
  >
  
  > head(anno_maf[1:3,1:4])
                       Tumor_Sample_Barcode Chromosome Start_Position End_Position
  1: LP2000107-DNA_A01_vs_LP2000102-DNA_A01       chr5      137536800    137536803
  2: LP2000330-DNA_A01_vs_LP2000316-DNA_A01      chr11       64012229     64012231
  3: LP2000330-DNA_A01_vs_LP2000316-DNA_A01      chr17       41720917     41720917
  > 
  
  > unique(anno_maf$Tumor_Sample_Barcode)
    [1] "LP2000107-DNA_A01_vs_LP2000102-DNA_A01" "LP2000330-DNA_A01_vs_LP2000316-DNA_A01" "LP2000332-DNA_A01_vs_LP2000323-DNA_A01"
    [4] "LP2000333-DNA_A01_vs_LP2000324-DNA_A01" "LP6005334-DNA_A02_vs_LP6005333-DNA_A02" "LP6005334-DNA_C01_vs_LP6005333-DNA_C01"
  
  I want to remove everything thing from vs onward in anno_maf$Tumor_Sample_Barcode, for example leaving LP2000107-DNA_A01 from LP2000107-DNA_A01_vs_LP2000102-DNA_A01 but I don't know how to do that
  Any help?
  
  user3541: sub() is the way to go.
  Your pattern is your regular expression: Check for "_vs_" followed by any character (provided with .) for an undefined length (provided with *).
  my_text <- "LP2000107-DNA_A01_vs_LP2000102-DNA_A01"
  
  sub(pattern = "_vs_.*",
      replacement = "",
      x = my_text)
  
  [1] "LP2000107-DNA_A01"
  
  
original_text: 4595: <p>I have a too big data frame</p>
  
  <pre><code>&gt; dim(anno_maf)
  [1] 2635299     132
  &gt;
  
  &gt; head(anno_maf[1:3,1:4])
                       Tumor_Sample_Barcode Chromosome Start_Position End_Position
  1: LP2000107-DNA_A01_vs_LP2000102-DNA_A01       chr5      137536800    137536803
  2: LP2000330-DNA_A01_vs_LP2000316-DNA_A01      chr11       64012229     64012231
  3: LP2000330-DNA_A01_vs_LP2000316-DNA_A01      chr17       41720917     41720917
  &gt; 
  
  &gt; unique(anno_maf$Tumor_Sample_Barcode)
    [1] "LP2000107-DNA_A01_vs_LP2000102-DNA_A01" "LP2000330-DNA_A01_vs_LP2000316-DNA_A01" "LP2000332-DNA_A01_vs_LP2000323-DNA_A01"
    [4] "LP2000333-DNA_A01_vs_LP2000324-DNA_A01" "LP6005334-DNA_A02_vs_LP6005333-DNA_A02" "LP6005334-DNA_C01_vs_LP6005333-DNA_C01"
  </code></pre>
  
  <p>I want to remove everything thing from <code>vs</code> onward in <code>anno_maf$Tumor_Sample_Barcode</code>, for example leaving <code>LP2000107-DNA_A01</code> from <code>LP2000107-DNA_A01_vs_LP2000102-DNA_A01</code> but I don't know how to do that</p>
  
  <p>Any help?</p>
   3541: <p><code>sub()</code> is the way to go.</p>
  
  <p>Your pattern is your regular expression: Check for "_vs_" followed by any character (provided with <code>.</code>) for an undefined length (provided with <code>*</code>).</p>
  
  <pre><code>my_text &lt;- "LP2000107-DNA_A01_vs_LP2000102-DNA_A01"
  
  sub(pattern = "_vs_.*",
      replacement = "",
      x = my_text)
  
  [1] "LP2000107-DNA_A01"
  </code></pre>
  