Reanding a windows file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Reanding a windows file

Alexandra R. M. de Almeida
Dear R users
 
 Some one knows how to read a windows file with the adress like "D:\CSV\Work\test.csv" without change the "\" by "/" by myself?!
 There is some function or parameter that read like the adress windows form.
 I tried to search somethig to substitute the "\" by "/", but I don't find...
 
 Thanks
 
 Alexandra Almeida
 


  Alexandra R. Mendes de Almeida

                                                 


               
---------------------------------

Internet rápida e grátis. Instale o discador agora!
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Reanding a windows file

Peter Dalgaard
"Alexandra R. M. de Almeida" <[hidden email]> writes:

> Dear R users
>  
>  Some one knows how to read a windows file with the adress like
"D:\CSV\Work\test.csv" without change the "\" by "/" by myself?!
>  There is some function or parameter that read like the adress windows form.
>  I tried to search somethig to substitute the "\" by "/", but I don't find...

Well, there's no problem with the backslashed form except if you try
copying it literally into R source code. If you do, you run into
problems with R interpreting the backslash as an escape character,
which itself needs to be escaped ("doubling the backslashes"). You
might for instance proceed as follows:

> x <- readLines(,1) # input data on next line
D:\CSV\Work\test.csv
> x
[1] "D:\\CSV\\Work\\test.csv"
> mydata <- read.csv(x)

Notice that x as such has only single backslashes, it is just the
print routine that inserts escape characters:

> cat(x,"\n")
D:\CSV\Work\test.csv
> nchar(x)
[1] 20

123456789*123456789*




--
   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
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Reanding a windows file

Duncan Murdoch
In reply to this post by Alexandra R. M. de Almeida
On 2/16/2006 12:39 PM, Alexandra R. M. de Almeida wrote:
> Dear R users
>  
>  Some one knows how to read a windows file with the adress like "D:\CSV\Work\test.csv" without change the "\" by "/" by myself?!
>  There is some function or parameter that read like the adress windows form.
>  I tried to search somethig to substitute the "\" by "/", but I don't find...

Use file.choose(), and don't type anything at all.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html