On May 14, 2012, at 6:35 AM, Berend Hasselman wrote:
On 14-05-2012, at 12:07, Wincent wrote:
Emm, my bad.
I meant str <- "abc\d".
Any ideas?
gsub("\\\\", "", str)
#1: One cannot execute: str <- "abc\d" , at least on my machine,
since that throws an error because "\d" is an "unrecognized escape".
#2: If the string has a backslash as its fourth character then it
would need to be created with:
str <- "abc\\d"
(Then Berend's gsub would succeed.)
#3: If the string contains an ASCII cntrl-d. then the needed gsub
command would be:
str <- "abc\004"
gsub("\\\004", "new", str)
[1] "abcnew"
--
David Winsemius, MD
West Hartford, CT
______________________________________________
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.