Replace character at certain location within string
Try substr()
substr(s, 4, 4) <- "t"
> s
#[1] "test123"
We can use sub
sub("(.{3}).", "\\1t", s)
#[1] "test123"
Try substr()
substr(s, 4, 4) <- "t"
> s
#[1] "test123"
We can use sub
sub("(.{3}).", "\\1t", s)
#[1] "test123"