Re: [R] Replacing backslashes with slashes

2006-01-05 Thread Duncan Golicher
It is often convenient to quickly set the working directory to a path copied onto the windows clipboard. A simple trick I have been using for a while is along the lines given in the previous posts. setwd.clip-function() { options(warn=-1) setwd(gsub(,/,readLines(clipboard)))

[R] Replacing backslashes with slashes

2006-01-04 Thread yvonnick noel
Hello, I've seen this question asked in the archives but no clear reply or solution provided. So, just to be sure it is not possible in R: Can I replace backslashes with slashes in a string ? I am writing a GUI for R with the Rpad library. I have a browse button for data loading and Windows

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Ted Harding
On 04-Jan-06 yvonnick noel wrote: Hello, I've seen this question asked in the archives but no clear reply or solution provided. So, just to be sure it is not possible in R: Can I replace backslashes with slashes in a string ? I am writing a GUI for R with the Rpad library. I have a

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Prof Brian Ripley
On Wed, 4 Jan 2006, yvonnick noel wrote: Hello, I've seen this question asked in the archives but no clear reply or solution provided. I've seen the answer many times: what were you searching on? So, just to be sure it is not possible in R: Can I replace backslashes with slashes in a

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Elizabeth Lawson
Try name-C:\\myfile.txt name [1] C:\\myfile.txt gsub(([\\]),\\/,name) [1] C:/myfile.txt yvonnick noel [EMAIL PROTECTED] wrote: Hello, I've seen this question asked in the archives but no clear reply or solution provided. So, just to be sure it is not possible in R: Can I replace

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread yvonnick noel
It would work with gsub(,/,c:\\My Documents\\data.dat) [1] c:/My Documents/data.dat which of course is not your case :( Absolutely. What I get from the interface is the string c:\My Documents\data.dat and NOT the string c:\\My Documents\\data.dat. That is why the solutions previously

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread yvonnick noel
You need one of gsub(,/,c:\\My Documents\\data.dat) gsub(\\,/,c:\\My Documents\\data.dat, fixed = TRUE) chartr(\\, /, c:\\My Documents\\data.dat) The string I get is an ASCII string in a web page, through the use of an INPUT type=file ... tag (with a browse button). This string is

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Prof Brian Ripley
On Wed, 4 Jan 2006, yvonnick noel wrote: You need one of gsub(,/,c:\\My Documents\\data.dat) gsub(\\,/,c:\\My Documents\\data.dat, fixed = TRUE) chartr(\\, /, c:\\My Documents\\data.dat) The string I get is an ASCII string in a web page, through the use of an INPUT type=file ...

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread yvonnick noel
You really don't understand what I wrote (and it is in many places in the R documentation). How are you getting that string into R? OK. A practical example is probably necessary here. I have rewritten a small Rpad page to show you what I mean. It is copied at the end of this post. Just save

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Peter Dalgaard
yvonnick noel [EMAIL PROTECTED] writes: You need one of gsub(,/,c:\\My Documents\\data.dat) gsub(\\,/,c:\\My Documents\\data.dat, fixed = TRUE) chartr(\\, /, c:\\My Documents\\data.dat) The string I get is an ASCII string in a web page, through the use of an INPUT type=file

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Ted Harding
On 04-Jan-06 yvonnick noel wrote: [...] The string I get is an ASCII string in a web page, through the use of an INPUT type=file ... tag (with a browse button). This string is caught as is by R through the Rpad interface (using tcltk as a mini local webserver). So it is not manually input

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread Seth Falcon
Hi Yvonnick, On 4 Jan 2006, [EMAIL PROTECTED] wrote: I am writing a GUI for R with the Rpad library. I have a browse button for data loading and Windows return a path string with backslashes. I need to convert them into slashes to use the string with read.table. Can you provide some further

Re: [R] Replacing backslashes with slashes

2006-01-04 Thread yvonnick noel
Ted, For example, if I make a file names.txt with contents c:\My Documents\data.dat (even without quotes) then A-readLines(names.txt,n=1) A [1] c:\\My Documents\\data.dat so the result is now in the format such that gsub will work. E.g. gsub(,/,readLines(names.txt,n=1))

[R] replacing backslashes with slashes using gsub

2004-05-24 Thread witek
Hi! I am trying to replace backslashes with slashes using gsub (R1.9.0 on XP) gsub(,/,D:\Prog\R\rw1090\library\cluster\libs) [1] D:ProgR\rw1090libraryclusterlibs ? Sincerely Eryk __ [EMAIL PROTECTED] mailing list

Re: [R] replacing backslashes with slashes using gsub

2004-05-24 Thread Jeff Gentry
gsub(,/,D:\Prog\R\rw1090\library\cluster\libs) [1] D:ProgR\rw1090libraryclusterlibs Probably not the best way, but what about escaping all the backslashes in the original string? gsub(,/,D:\\Prog\\R\\rw1090\\library\\cluster\\libs) __ [EMAIL