[R] How to remove $ (Dollar sign) from string

Ivan Calandra ivan.calandra at u-bourgogne.fr
Tue Apr 10 13:48:12 CEST 2012


Hi,

Try with a double back slash:
sub("\\$","","ABC$DEF")

HTH,
Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra


Le 10/04/12 13:34, Nevil Amos a écrit :
> 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(\"
>
> Thanks



More information about the R-help mailing list