tags:

views:

113

answers:

2

I have a remote folder on a webserver containing data. I access the data using:

myData <-read.table("http://.../myData.csv", sep=',', header=T)

Is there a way to password protect the remote folder and enter the authorisation in the above command?

Thx.

+8  A: 

You could use the RCurl package:

require("RCurl")
read.table(textConnection(getURL("http://.../data.csv",
                                 userpwd = "user:pass")),
           sep=",", header=TRUE)
rcs
many thanks. totally works.
John
If you feel this answers the question you could click on the tick by the answer to accept it ;)
rcs
+3  A: 

Generally speaking, you can embed usernames and passwords in the URL, like so:

http://username:[email protected]/path/to/file.dat

chrisamiller
To be precise, it is not that R is just trying to connect to this address, it is just a convention how performing HTTP/FTP/... auth is implemented, and indeed it is used by many programs, also R. But, for instance, web browsers tend behave strange with it due to the security reasons.
mbq