Replace(data = 232,from = 2,to = 1)
Replace(data = c(232,'a4b'),
from = c(2,'.*4'),to = 1,
pattern = c('a:e','b:h'))
df = data.frame(
a = c(232, 452),
b = c("nba", "cba")
)
Replace(data = df,
from = 2,to = 1,
pattern = c('a:e','b:h'))
Run the code above in your browser using DataLab