Re: [R] How to convert "c:\a\b" to "c:/a/b"?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 30 Jun 2005 - 08:16:23 EST

One other comment. Ninotech Path Copy, which can be found at:

  http://home.worldonline.dk/ninotech/

is a free Windows utility that appears in the Windows Explorer context menu (i.e. it appears as the Copy Path menu entry when you right click any file in Windows Explorer). I had forgotten about it since even though I had installed it a long time ago I hardly ever use it. When one right clicks and chooses Copy Path one is given a number of different ways in which to copy the path. Using the Setup submenu (i.e. right click any file and choose Setup) one can define additional ways and its quite easy to define a new method which replaces backslashes with forward slashes as it copies -- in fact, there is a check box specifically for this.

On 6/27/05, Spencer Graves <spencer.graves@pdf.com> wrote:
> Hi, Gabor, James, et al.:
>
> Thanks for the help. I'm unable to get "scan('clipboard', what='',
> allowEscapes=FALSE))" to work reliably on my system using Rgui under
> Windows XP, R 2.1.1 patched. However, "file.choose()" works like a charm.
>
> Thanks again, everyone.
> spencer graves
>
> Gabor Grothendieck wrote:
> > Try using file.choose() to locate the file instead of Windows Explorer. That
> > will return the name in a form useable within R.
> >
> > On 6/27/05, Spencer Graves <spencer.graves@pdf.com> wrote:
> >
> >> Thanks, Dirk, Gabor, Eric:
> >>
> >> You all provided appropriate solutions for the stated problem.
> >>Sadly, I oversimplified the problem I was trying to solve: I copy a
> >>character string giving a DOS path from MS Windows Explorer into an R
> >>script file, and I get something like the following:
> >>
> >> D:\spencerg\statmtds\R\Rnews
> >>
> >> I want to be able to use this in R with its non-R meaning, e.g., in
> >>readLine, count.fields, read.table, etc., after appending a file name.
> >>Your three solutions all work for my oversimplified toy example but are
> >>inadequate for the problem I really want to solve.
> >>
> >> Thanks,
> >> spencer graves
> >>
> >>Gabor Grothendieck wrote:
> >>
> >>
> >>>On 6/27/05, Dirk Eddelbuettel <edd@debian.org> wrote:
> >>>
> >>>
> >>>>On 26 June 2005 at 20:30, Spencer Graves wrote:
> >>>>| How can one convert back slashes to forward slashes, e.g, changing
> >>>>| "c:\a\b" to "c:/a/b"? I tried the following:
> >>>>|
> >>>>| > gsub("\\\\", "/", "c:\a\b")
> >>>>| [1] "c:\a\b"
> >>>>
> >>>>This does work, provided you remember that single backslashed "don't exist"
> >>>>as e.g. \a is a character in itself. So use doubles are you should be fine:
> >>>>
> >>>>
> >>>>
> >>>>>gsub("\\\\", "/", "c:\\a\\b")
> >>>>
> >>>>[1] "c:/a/b"
> >>>>
> >>>
> >>>
> >>>Also, if one finds four backslashes confusing one can avoid the use
> >>>of four via any of these:
> >>>
> >>>gsub("[\\]", "/", "c:\\a\\b")
> >>>gsub("\\", "/", "c:\\a\\b", fixed = TRUE)
> >>>chartr("\\", "/", "c:\\a\\b")
> >>>
> >>>______________________________________________
> >>>R-help@stat.math.ethz.ch mailing list
> >>>https://stat.ethz.ch/mailman/listinfo/r-help
> >>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >>
> >>--
> >>Spencer Graves, PhD
> >>Senior Development Engineer
> >>PDF Solutions, Inc.
> >>333 West San Carlos Street Suite 700
> >>San Jose, CA 95110, USA
> >>
> >>spencer.graves@pdf.com
> >>www.pdf.com <http://www.pdf.com>
> >>Tel: 408-938-4420
> >>Fax: 408-280-7915
> >>
> >
> >
>
> --
> Spencer Graves, PhD
> Senior Development Engineer
> PDF Solutions, Inc.
> 333 West San Carlos Street Suite 700
> San Jose, CA 95110, USA
>
> spencer.graves@pdf.com
> www.pdf.com <http://www.pdf.com>
> Tel: 408-938-4420
> Fax: 408-280-7915
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 30 08:20:13 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:07 EST