Re: [R] Reanding a windows file

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Tue 21 Feb 2006 - 09:33:49 EST

"Alexandra R. M. de Almeida" <alexandrarma@yahoo.com.br> 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
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
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 Tue Feb 21 09:57:47 2006

This archive was generated by hypermail 2.1.8 : Tue 21 Feb 2006 - 14:38:23 EST