Re: [R] gsub() could not replace my string

2016-10-07 Thread William Dunlap via R-help
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=

[R] gsub() could not replace my string

2016-10-07 Thread Christofer Bogaso
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%"