[R] file path

David Winsemius dwinsemius at comcast.net
Mon May 14 16:16:20 CEST 2012


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



More information about the R-help mailing list