Hello everybody,
this might be a trivial question, but I have been unable to find this using
Google. I am trying to replace double backslashes with single backslashes using
gsub. There seems to be some unexpected behaviour with regards to the
replacement string "\\". The following example uses the string C:\\ which should
be converted to C:\ .
> gsub("\\\\", "\\", "C:\\")
[1] "C:"
> gsub("\\\\", "Test", "C:\\")
[1] "C:Test"
> gsub("\\\\", "\\\\", "C:\\")
[1] "C:\\"
I have observed similar behaviour for fixed=TRUE and perl=TRUE. I use R 2.14.1
64-bit on Windows 7.
Markus
--
Markus Elze
Department of Statistics
University of Warwick
Coventry
CV4 7AL
______________________________________________
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.