text: user4595: I have a .txt file; I have 139 unique sample IDs in sampleID column
  > head(mutations)
                                                                                sampleID chr     pos ref mut
  4 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1  920552   G   A
  5 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1350208   G   A
  6 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1447367   T   G
  7 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1909310   G   A
  8 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 2172675   G   C
  9 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 2846623   C   T
  > 
  
  > dim(mutations)
  [1] 3574407       5
  > 
  
  I want to change name of sample from 1 to 139 in R or Linux terminal but I don't know how to do that, any help please?
  Thanks 
  
  user6316: I believe that 
  uniqsampleID = 1:length(unique(mutations$sampleID))
  names(uniqsampleID) = unique(mutations$sampleID)
  mutations$sampleID = uniqsampleID[mutations$sampleID]
  
  should work, assuming mutations is a data frame.
  
  Explanation:
  1:N creates a vector of length N, containing 1, 2, ..., N. So using 1:length(X) will do this for each item in X, so 1:length(unique(mutations$sampleID)) should give you a vector of 1:139.
  Then names(uniqsampleID) = unique(mutations$sampleID) assigns to each of these numbers one of these sample IDs, which allows you to retrieve the sample number with uniqsampleID[mutations$sampleID].
  
original_text: 4595: <p>I have a .txt file; I have 139 unique sample IDs in sampleID column</p>
  
  <pre><code>&gt; head(mutations)
                                                                                sampleID chr     pos ref mut
  4 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1  920552   G   A
  5 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1350208   G   A
  6 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1447367   T   G
  7 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 1909310   G   A
  8 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 2172675   G   C
  9 LP2000107-DNA_A01_vs_LP2000102-DNA_A01__pv.1.6__rg.grch37_g1k__al.bwa_mem__.snp.pass   1 2846623   C   T
  &gt; 
  
  &gt; dim(mutations)
  [1] 3574407       5
  &gt; 
  </code></pre>
  
  <p>I want to change name of sample from 1 to 139 in R or Linux terminal but I don't know how to do that, any help please?</p>
  
  <p>Thanks </p>
   6316: <p>I believe that </p>
  
  <pre><code>uniqsampleID = 1:length(unique(mutations<span class="math-container">$sampleID))
  names(uniqsampleID) = unique(mutations$</span>sampleID)
  mutations<span class="math-container">$sampleID = uniqsampleID[mutations$</span>sampleID]
  </code></pre>
  
  <p>should work, assuming <code>mutations</code> is a data frame.</p>
  
  <hr>
  
  <p>Explanation:</p>
  
  <p><code>1:N</code> creates a vector of length N, containing 1, 2, ..., N. So using <code>1:length(X)</code> will do this for each item in X, so <code>1:length(unique(mutations$sampleID))</code> should give you a vector of <code>1:139</code>.</p>
  
  <p>Then <code>names(uniqsampleID) = unique(mutations$sampleID)</code> assigns to each of these numbers one of these sample IDs, which allows you to retrieve the sample number with <code>uniqsampleID[mutations$sampleID]</code>.</p>
  