R - fixed argument in gsub(): match as is

25 Dec 2018

myStrings <- c(“20.january”, “4.april”, “5.may”)

fixed will match the first argument as is

Replace literal dots with 0

gsub(“.”, “0”, myStrings, fixed = TRUE)

[1] “200january” “40april” “50may”

This will replace all characters with zeros

gsub(“.”, “0”, myStrings)

[1] “0000000000” “0000000” “00000”

[ R  string  regexpr  ]