On Tue, Apr 10, 2012 at 7:34 AM, Nevil Amos <nevil.a...@monash.edu> wrote: > How do I remove a "$" character from a string sub() and gsub() with "$" or > "\$" as pattern do not work. >> sub("$","","ABC$DEF") > [1] "ABC$DEF" >> sub("\$","","ABC$DEF") > Error: '\$' is an unrecognized escape in character string starting "\$" >> sub(\$,"","ABC$DEF") > Error: unexpected input in "sub(\" >
Here are three ways: sub("$", "", "ABC$DEF", fixed = TRUE) sub("\\$", "", "ABC$DEF") sub("[$]", "", "ABC$DEF") -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.