Replace a prefix of a string
I think you are looking for gsub function:

a$Tumor_Sample_Barcode &lt;- gsub("A","res",a$Tumor_Sample_Barcode)


If you prefer, you can use the str_replace_all function from stringr package. But it tooks a little bit more time than gsub:

Dummy data

seq = as.factor(paste0("A",1:21))
library(data.table)
dt &lt;- data.table(Barcode = rep(seq,10000),
                 Value = rnorm(210000))


Test of gsub vs str_replace_all

&gt; system.time(dt$Barcode &lt;- gsub("A","res",dt$Barcode))
   user  system elapsed 
  0.077   0.000   0.077 

&gt; system.time(dt$Barcode &lt;- str_replace_all(dt$Barcode,"A","res"))
   user  system elapsed 
  0.123   0.004   0.126 
```