In data martedì 10 aprile 2012 13:34:13, Nevil Amos ha scritto:
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 \$
Why you need a double backslash is alluded
to in Circle 8.1.23 of 'The R Inferno'.
http://www.burns-stat.com/pages/Tutor/R_inferno.pdf
Pat
On 22/04/2012 10:18, Giuseppe Marinelli wrote:
In data martedì 10 aprile 2012 13:34:13, Nevil Amos ha scritto:
How do I remove a $ character from a
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
--
Nevil Amos
Molecular
Dear Nevil,
You have the escape the backslash:
sub(\\$, , ABC$DEF)
[1] ABCDEF
I hope this helps,
John
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
On 10-Apr-2012 11:34:13 Nevil Amos 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
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.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra
Le 10/04/12 13:34,
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 \$
7 matches
Mail list logo