I want to replace \\ with \ in:
str <-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"
and tried:
gsub("\\\\", "\\", str)
but this removes the \\ without replacing them by \
Any help much appreciated,
Kay
-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------
--
View this message in context: http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.
replace double backslash with singel backslash
7 messages · jim holtman, Michael Friendly, Gene Leynes +2 more
what is the problem that you are trying to solve? you need the double \\ since they have a special meaning in quoted strings. in this case they represent a since backslash. if you really had a single one, then something like this '\n' would be a carriage return. Sent from my iPad
On Nov 4, 2011, at 5:35, Kay Cichini <Kay.Cichini at uibk.ac.at> wrote:
I want to replace \\ with \ in:
str <-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"
and tried:
gsub("\\\\", "\\", str)
but this removes the \\ without replacing them by \
Any help much appreciated,
Kay
-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------
--
View this message in context: http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at 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.
On 11/4/2011 5:35 AM, Kay Cichini wrote:
I want to replace \\ with \ in:
str<-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"
and tried:
gsub("\\\\", "\\", str)
but this removes the \\ without replacing them by \
You may be able to avoid this simply by using forward slashes in path names. Otherwise, ?normalizePath may help.
Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111104/8ab8e6e8/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111104/1b98ed9f/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111104/1f87386b/attachment.pl>
4 days later
Thanks, that helped! Yours, Kay Zitat von Gene Leynes <gleynes+r at gmail.com>:
I think that people are afraid to say "You can't do that in R"... But I think the real answer is: you can't do that in R. Although, it is helpful to understand Jeff's reply. I hadn't fully realized why this particular problem occurs before reading that. It's odd to me that // and / are both stored as /, but that makes sense given my experience in R. Also, the other replies are good advice, working with R's path functions or sticking with forward slashes is the way to go (don't fight the assimilation, the borg needs you). Personally, I think some of these seemingly small problems actually encumber R's mainstream adoption quite a bit, but then I'm not the one writing R. Plus, it's is still pretty dang awesome even with its minor annoyances. On Fri, Nov 4, 2011 at 8:45 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>wrote:
Your str does not have any double backslashes to replace. You need to
revisit the concept of escape characters in the documentation. In brief,
every "\\" in a quoted string is actually a single character as stored in
memory.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Kay Cichini <Kay.Cichini at uibk.ac.at> wrote:
I want to replace \\ with \ in:
str <-
"C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg"
and tried:
gsub("\\\\", "\\", str)
but this removes the \\ without replacing them by \
Any help much appreciated,
Kay
-----
------------------------
Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck
------------------------
--
View this message in context:
http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.html
Sent from the R help mailing list archive at Nabble.com.
_____________________________________________ R-help at 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. [[alternative HTML version deleted]] ______________________________________________ R-help at 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.