Misunderstanding escape (backslash)
"Gabor Grothendieck" <ggrothendieck at gmail.com> writes:
On 10/16/06, Frank McCown <fmccown at cs.odu.edu> wrote:
Forgive my ignorance, but shouldn't '\\' be converted into '\' in my string? In my output (below), you can see that '\\' remains '\\'.
> term = "mother\'s day" > term
[1] "mother's day"
> term = "mother\\\'s day" > term
[1] "mother\\'s day" <--- should be "mother\'s day"
I think this is just a matter of interpetation of the output:
strsplit("mother\\'s day", NULL)[[1]]
[1] "m" "o" "t" "h" "e" "r" "\\" "'" "s" " " "d" "a" "y"
cat("mother\\'s day", "\n")
mother\'s day
nchar("mother\\'s day")
[1] 13
And check out the new FAQ 7.37.... http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-backslash-behave-strangely-inside-strings_003f
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907