Either backslash the square brackets, as they have a special meaning
(character range) in regular expressions, or use the fixed=TRUE argument to
indicate that your pattern is not a regular expression.
> gsub("\\[NA\\]NA%", "", "[NA]NA%abcde")
[1] "abcde"
> gsub("[NA]NA%", "", "[NA]NA%abcde", fixed=
Hello again,
I have few many string elements, and some of those elements contain a
special phrase as '"[NA]NA%", which I planned to replace by some
Blank. So I tried with below code in R
> gsub("[NA]NA%", "", "[NA]NA%abcde")
[1] "[NA]NA%abcde"
It appears that, my code could not replace "[NA]NA%"
2 matches
Mail list logo