Dear all, in the past I have been able to access websites with data directly. For example the following code works nicely mydata <- read.table("http://www.lifetable.de/data/MPIDR/POL_2004.txt", header=TRUE) But what happens if I need a username and password (a different site)? How do I do that? Or is it not possible to this in R? I tried something like this mydata.frame <- read.table("myusr:mypswd at www.mydata.com/adir/afile.txt") but it did not work. I'd appreciate any hints. My platform is Win32 (and I am actually running R 2.3.1, but I guess (hope!) this is not the reason. At least I checked the NEWS file whether any changes appeared since 2.3.1 which could affect this behavior). Thanks, Roland
Roland Rau wrote:> Dear all, > > in the past I have been able to access websites with data directly. For > example the following code works nicely > > mydata <- > read.table("http://www.lifetable.de/data/MPIDR/POL_2004.txt", header=TRUE) > > But what happens if I need a username and password (a different site)? > How do I do that? Or is it not possible to this in R? > I tried something like this > > mydata.frame <- read.table("myusr:mypswd at www.mydata.com/adir/afile.txt") > > but it did not work. > I'd appreciate any hints. > My platform is Win32 (and I am actually running R 2.3.1, but I guess > (hope!) this is not the reason. At least I checked the NEWS file whether > any changes appeared since 2.3.1 which could affect this behavior).In what way did it not work? The following seems to work for me: read.table("ftp://myusr:mypswd at mysite.org/mydir/test.dat")> Thanks, > Roland > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code.-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
On Wed, 16 May 2007, Roland Rau wrote:> Dear all, > > in the past I have been able to access websites with data directly. For > example the following code works nicely > > mydata <- > read.table("http://www.lifetable.de/data/MPIDR/POL_2004.txt", header=TRUE) > > But what happens if I need a username and password (a different site)? > How do I do that? Or is it not possible to this in R? > I tried something like this > > mydata.frame <- read.table("myusr:mypswd at www.mydata.com/adir/afile.txt") > > but it did not work.Well, it could not. You need ftp:// or http:// for this to be a URL. This ought to work for ftp:, but AFAIK not for http:. You could always try --internet2: if it works in IE, it will probably also work in R.> I'd appreciate any hints. > My platform is Win32 (and I am actually running R 2.3.1, but I guess > (hope!) this is not the reason. At least I checked the NEWS file whether > any changes appeared since 2.3.1 which could affect this behavior). > > Thanks, > Roland > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at 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