This is an FAQ (both in the main FAQ and the rw-FAQ)

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-file-names-work-in-Windows_003f
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file

You may find it easier to map your network drives: most users do.

See also ?Quotes in R.

On Fri, 2 Jan 2009, Harsh wrote:

Hello,

I'm trying to pull data from a network drive on a windows machine. The
location is read into a string <rem> and then used later with a data
input command.

rem<- "\\192.192.192.3\Shared\iris1.csv"
Warning messages:
1: '\S' is an unrecognized escape in a character string
2: '\i' is an unrecognized escape in a character string
3: unrecognized escapes removed from "\\192.168.16.3\Shared\iris1.csv"

When using a data input operation

datafile<- read.csv(rem,header= T, sep = ",")
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") :
 cannot open file '\192.192.192.3Sharediris1.csv': No such file or directory

I have tried to use strsplit to split on "\\"

strsplit(rem,"\\")
Error in strsplit(rem, "\\") : invalid split pattern '\'
In addition: Warning message:
In strsplit(rem, "\\") : regcomp error:  'Trailing backslash'

Also, I tried to split to extract all characters and this is what I obtained.

print(strsplit(rem,""))
[[1]]
[1] "\\" "1"  "9"  "2"  "."  "1"  "6"  "8"  "."  "1"  "6"  "."  "3"  "S"  "h"
[16] "a"  "r"  "e"  "d"  "i"  "r"  "i"  "s"  "1"  "."  "c"  "s"  "v"


The problem is that, I cannot check for each character and if "\",
convert it to "/".

Ofcourse, if I were to assign

rem<- "//192.192.192.3/Shared/iris1.csv"

Then rem can be used successfully
datafile<- read.csv(rem,header= T, sep = ",")

Alternately, I would like to know, if the network drive were to have a
username and password,
how would I be able to pass those parameters in read.csv below

datafile<- read.csv("\\192.168.16.3\Shared\iris1.csv username:user
password:user",header= T, sep = ",")

Clearly not, do read the help page as requested.



Thank you,

Harsh Singhal
Mu Sigma Decision Systems Inc.,
Chicago, IL
USA

______________________________________________
R-help@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.


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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.

Reply via email to